Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

adding a signal of support on win32. #1796

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 116 additions & 0 deletions deps/uv/include/uv-private/linklist.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
#ifndef _linklist_h_
#define _linklist_h_ 1

//
//typedef struct _SLINK{
// _SLINK* _next;
//} SLINK,*PSLINK;


//template< typename PSLINK >
//inline void SLINK_Initialize(PSLINK _head )
//{ (_head)->_next = NULL; }
#define SLINK_Initialize(_head) ((_head)->_next = NULL)

//template< typename PSLINK >
//inline bool SLINK_IsEmpty(PSLINK _head )
//{ return ((_head)->_next == NULL);}
#define SLINK_IsEmpty(_head) ((_head)->_next == NULL)

//template< typename PSLINK ,typename PVALUE >
//inline PVALUE SLINK_Pop(PSLINK _head )
//{
// PVALUE head_item = (_head)->_next;
// (_head)->_next = ((_head)->_next->_next);
// return head_item;
//}
#define SLINK_Pop(_head) (_head)->_next;\
(_head)->_next = (_head)->_next->_next;

//template< typename PSLINK ,typename PVALUE >
//inline void SLINK_Push(PSLINK _head, PVALUE _link)
//{
// (_link)->_next = (_head)->_next;
// (_head)->_next = (_link);
//}
#define SLINK_Push(_head, _link) (_link)->_next = (_head)->_next; \
(_head)->_next = (_link)

///////////////////////////////////////////////////////////////////////////////////
/////////////////////////////DOUBLE///LINK/////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////

//
//typedef struct _DLINK{
// _DLINK* _prev;
// _DLINK* _next;
//} DLINK,*PDLINK;

//template< typename PDLINK >
//void DLINK_Initialize(PDLINK _head)
//{
// (_head)->_next = (_head)->_prev = (_head);
//}
#define DLINK_Initialize(_head) ((_head)->_next = (_head)->_prev = (_head))

//template< typename PDLINK >
//bool DLINK_IsEmpty(PDLINK)
//{
// return ((_head)->_next == (_head));
//}
#define DLINK_IsEmpty(_head) ((_head)->_next == (_head))

//template< typename PDLINK ,typename PVALUE >
//inline void DLINK_InsertNext(PDLINK _head,PVALUE _dlink)
//{
// (_dlink)->_next = (_head)->_next;
// (_dlink)->_prev = (_head);
// (_head)->_next->_prev = (_dlink);
// (_head)->_next = (_dlink);
//}
#define DLINK_InsertNext(_head,_dlink) (_dlink)->_next = (_head)->_next;\
(_dlink)->_prev = (_head);\
(_head)->_next->_prev = (_dlink);\
(_head)->_next = (_dlink)

//template< typename PDLINK ,typename PVALUE >
//inline void DLINK_InsertPrev(PDLINK _head,PVALUE _dlink )
//{
// (_dlink)->_prev = (_head)->_prev;
// (_dlink)->_next = (_head);
// (_head)->_prev->_next = (_dlink);
// (_head)->_prev = (_dlink);
//}
#define DLINK_InsertPrev(_head,_dlink) (_dlink)->_prev = (_head)->_prev;\
(_dlink)->_next = (_head);\
(_head)->_prev->_next = (_dlink);\
(_head)->_prev = (_dlink)
//template< typename PDLINK >
//inline void DLINK_Remove(PDLINK _dlink)
//{
// (_dlink)->_prev->_next = (_dlink)->_next;
// (_dlink)->_next->_prev = (_dlink)->_prev;
//}
#define DLINK_Remove(_dlink) (_dlink)->_prev->_next = (_dlink)->_next;\
(_dlink)->_next->_prev = (_dlink)->_prev
//template< typename PDLINK ,typename PVALUE >
//inline PVALUE DLINK_ExtructPrev(PDLINK _head )
//{
// PVALUE v = (_head)->_prev;
// DLINK_Remove((_head)->_prev);
// return v;
//}
#define DLINK_ExtructPrev(_head) (_head)->_prev;\
DLINK_Remove((_head)->_prev)
//template< typename PDLINK ,typename PVALUE >
//inline PVALUE DLINK_ExtructNext(PDLINK _head)
//{
// PVALUE v = (_head)->_next;
// DLINK_Remove((_head)->_next);
// return v;
//}
#define DLINK_ExtructNext(_head) (_head)->_next;\
DLINK_Remove((_head)->_next)


#endif // _linklist_h_
8 changes: 8 additions & 0 deletions deps/uv/include/uv-private/uv-win.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ RB_HEAD(uv_timer_tree_s, uv_timer_s);
uv_handle_t* endgame_handles; \
/* The head of the timers tree */ \
struct uv_timer_tree_s timers; \
/* The head of the timers tree */ \
struct uv_signal_s signal_handles; \
/* Lists of active loop (prepare / check / idle) watchers */ \
uv_prepare_t* prepare_handles; \
uv_check_t* check_handles; \
Expand Down Expand Up @@ -182,6 +184,12 @@ RB_HEAD(uv_timer_tree_s, uv_timer_s);
struct { uv_pipe_connection_fields }; \
};

#define UV_SIGNAL_PRIVATE_FIELDS \
struct uv_signal_s* _prev; \
struct uv_signal_s* _next; \
int signum; \
uv_signal_cb signal_cb;

/* TODO: put the parser states in an union - TTY handles are always */
/* half-duplex so read-state can safely overlap write-state. */
#define UV_TTY_PRIVATE_FIELDS \
Expand Down
27 changes: 26 additions & 1 deletion deps/uv/include/uv.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ typedef struct uv_udp_s uv_udp_t;
typedef struct uv_pipe_s uv_pipe_t;
typedef struct uv_tty_s uv_tty_t;
typedef struct uv_timer_s uv_timer_t;
typedef struct uv_signal_s uv_signal_t;
typedef struct uv_prepare_s uv_prepare_t;
typedef struct uv_check_s uv_check_t;
typedef struct uv_idle_s uv_idle_t;
Expand Down Expand Up @@ -127,6 +128,7 @@ typedef void (*uv_shutdown_cb)(uv_shutdown_t* req, int status);
typedef void (*uv_connection_cb)(uv_stream_t* server, int status);
typedef void (*uv_close_cb)(uv_handle_t* handle);
typedef void (*uv_timer_cb)(uv_timer_t* handle, int status);
typedef void (*uv_signal_cb)(uv_signal_t* handle, int status);
/* TODO: do these really need a status argument? */
typedef void (*uv_async_cb)(uv_async_t* handle, int status);
typedef void (*uv_prepare_cb)(uv_prepare_t* handle, int status);
Expand Down Expand Up @@ -213,7 +215,8 @@ typedef enum {
UV_ARES_TASK,
UV_ARES_EVENT,
UV_PROCESS,
UV_FS_EVENT
UV_FS_EVENT,
UV_SIGNAL
} uv_handle_type;

typedef enum {
Expand Down Expand Up @@ -739,6 +742,28 @@ int uv_async_init(uv_loop_t*, uv_async_t* async, uv_async_cb async_cb);
int uv_async_send(uv_async_t* async);



/*
* uv_signal_t is a subclass of uv_handle_t.
*
* Wraps libev's ev_signal watcher. Used to get woken up at a specified time
* in the future.
*/
struct uv_signal_s {
UV_HANDLE_FIELDS
UV_SIGNAL_PRIVATE_FIELDS
};


void uv_signal_registerHandler(uv_loop_t* loop);
void uv_signal_unregisterHandler(uv_loop_t* loop);

int uv_signal_init(uv_loop_t*, uv_signal_t* handle, uv_signal_cb cb, int signum);

int uv_signal_start(uv_signal_t* handle);

int uv_signal_stop(uv_signal_t* handle);

/*
* uv_timer_t is a subclass of uv_handle_t.
*
Expand Down
1 change: 1 addition & 0 deletions deps/uv/src/win/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ static void uv_loop_init(uv_loop_t* loop) {
loop->endgame_handles = NULL;

RB_INIT(&loop->timers);
DLINK_Initialize(&loop->signal_handles);

loop->check_handles = NULL;
loop->prepare_handles = NULL;
Expand Down
10 changes: 10 additions & 0 deletions deps/uv/src/win/handle.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ uv_handle_type uv_guess_handle(uv_file file) {

int uv_is_active(uv_handle_t* handle) {
switch (handle->type) {
case UV_SIGNAL:
case UV_TIMER:
case UV_IDLE:
case UV_PREPARE:
Expand Down Expand Up @@ -117,6 +118,11 @@ void uv_close(uv_handle_t* handle, uv_close_cb cb) {
uv_want_endgame(loop, handle);
}
return;

case UV_SIGNAL:
uv_signal_stop((uv_signal_t*)handle);
uv_want_endgame(loop, handle);
return;

case UV_TIMER:
uv_timer_stop((uv_timer_t*)handle);
Expand Down Expand Up @@ -196,6 +202,10 @@ void uv_process_endgames(uv_loop_t* loop) {
uv_udp_endgame(loop, (uv_udp_t*) handle);
break;

case UV_SIGNAL:
uv_signal_endgame(loop, (uv_signal_t*) handle);
break;

case UV_TIMER:
uv_timer_endgame(loop, (uv_timer_t*) handle);
break;
Expand Down
6 changes: 6 additions & 0 deletions deps/uv/src/win/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,16 @@
#include "../uv-common.h"

#include "tree.h"
#include "linklist.h"
#include "winapi.h"
#include "winsock.h"


/**
* signal
*/
void uv_signal_endgame(uv_loop_t* loop, uv_signal_t* handle);

/*
* Timers
*/
Expand Down
Loading