mirror of
https://github.com/darlinghq/darling-libkqueue.git
synced 2024-11-23 11:49:50 +00:00
more win32 stuff
git-svn-id: svn://svn.code.sf.net/p/libkqueue/code/trunk@392 fb4e3144-bc1c-4b72-a658-5bcd248dd7f7
This commit is contained in:
parent
926fbfd0ec
commit
0e1c7813bf
@ -172,19 +172,14 @@ extern "C" {
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
#define EVENT_QUEUE struct kqueue *
|
||||
|
||||
__declspec(dllexport) EVENT_QUEUE
|
||||
CreateEventQueue(void);
|
||||
__declspec(dllexport) int
|
||||
kqueue(void);
|
||||
|
||||
__declspec(dllexport) int
|
||||
WaitForEventQueueObject(EVENT_QUEUE kq, const struct kevent *changelist, int nchanges,
|
||||
kevent(int kq, const struct kevent *changelist, int nchanges,
|
||||
struct kevent *eventlist, int nevents,
|
||||
const struct timespec *timeout);
|
||||
|
||||
__declspec(dllexport) void
|
||||
DestroyEventQueue(EVENT_QUEUE);
|
||||
|
||||
#else
|
||||
int kqueue(void);
|
||||
int kevent(int kq, const struct kevent *changelist, int nchanges,
|
||||
|
@ -150,9 +150,6 @@ kqueue_get(int kq)
|
||||
int VISIBLE
|
||||
kqueue(void)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
static int kqueue_id = 0;
|
||||
#endif
|
||||
struct kqueue *kq;
|
||||
int tmp;
|
||||
|
||||
@ -171,13 +168,7 @@ kqueue(void)
|
||||
KQUEUE_DEBUG = (getenv("KQUEUE_DEBUG") == NULL) ? 0 : 1;
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
pthread_rwlock_wrlock(&kqtree_mtx);
|
||||
kqueue_id++;
|
||||
pthread_rwlock_unlock(&kqtree_mtx);
|
||||
kq->kq_sockfd[0] = kqueue_id;
|
||||
kq->kq_sockfd[1] = kqueue_id;
|
||||
#else
|
||||
#ifndef _WIN32
|
||||
if (socketpair(AF_UNIX, SOCK_STREAM, 0, kq->kq_sockfd) < 0)
|
||||
goto errout_unlocked;
|
||||
#endif
|
||||
|
@ -148,12 +148,8 @@ struct kqueue {
|
||||
fd_set kq_fds, kq_rfds;
|
||||
int kq_nfds;
|
||||
pthread_mutex_t kq_mtx;
|
||||
KQUEUE_PLATFORM_SPECIFIC;
|
||||
#ifdef __sun__
|
||||
int kq_port; /* see: port_create(2) */
|
||||
TAILQ_HEAD(event_buf_listhead,event_buf) kq_events;
|
||||
#endif
|
||||
volatile uint32_t kq_ref;
|
||||
volatile uint32_t kq_ref;
|
||||
KQUEUE_PLATFORM_SPECIFIC;
|
||||
RB_ENTRY(kqueue) entries;
|
||||
};
|
||||
|
||||
|
@ -29,5 +29,6 @@
|
||||
extern long int syscall (long int __sysno, ...);
|
||||
#define THREAD_ID ((pid_t) syscall(__NR_gettid))
|
||||
|
||||
#define KQUEUE_PLATFORM_SPECIFIC //
|
||||
|
||||
#endif /* ! _KQUEUE_LINUX_PLATFORM_H */
|
||||
|
@ -49,6 +49,13 @@ int solaris_kqueue_init(struct kqueue *);
|
||||
|
||||
void port_event_dequeue(port_event_t *, struct kqueue *);
|
||||
|
||||
/*
|
||||
* Additional members of struct kqueue
|
||||
*/
|
||||
#define KQUEUE_PLATFORM_SPECIFIC \
|
||||
int kq_port; \
|
||||
TAILQ_HEAD(event_buf_listhead,event_buf) kq_events
|
||||
|
||||
/*
|
||||
* Data structures
|
||||
*/
|
||||
|
@ -48,41 +48,21 @@ BOOL WINAPI DllMain(
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
__declspec(dllexport) EVENT_QUEUE
|
||||
CreateEventQueue(void)
|
||||
int
|
||||
windows_kqueue_init(struct kqueue *kq)
|
||||
{
|
||||
EVENT_QUEUE evq;
|
||||
int kqfd;
|
||||
|
||||
kqfd = kqueue();
|
||||
if (kqfd < 0)
|
||||
return (NULL);
|
||||
|
||||
|
||||
|
||||
evq = calloc(1, sizeof(*evq));
|
||||
if (evq == NULL)
|
||||
return (NULL);
|
||||
evq->kq_handle = CreateEvent(NULL, FALSE, FALSE, NULL);
|
||||
if (evq->kq_handle == NULL) {
|
||||
free(evq);
|
||||
return (NULL);
|
||||
kq->kq_handle = CreateEvent(NULL, FALSE, FALSE, NULL);
|
||||
if (kq->kq_handle == NULL) {
|
||||
dbg_perror("CreatEvent()");
|
||||
return (-1);
|
||||
}
|
||||
|
||||
return (evq);
|
||||
}
|
||||
|
||||
__declspec(dllexport) int
|
||||
WaitForEventQueueObject(EVENT_QUEUE kq, const struct kevent *changelist, int nchanges,
|
||||
struct kevent *eventlist, int nevents,
|
||||
const struct timespec *timeout)
|
||||
{
|
||||
return (0);
|
||||
}
|
||||
|
||||
__declspec(dllexport) void
|
||||
DestroyEventQueue(EVENT_QUEUE kq)
|
||||
void
|
||||
windows_kqueue_free(struct kqueue *kq)
|
||||
{
|
||||
CloseHandle(kq->notifier);
|
||||
CloseHandle(kq->kq_handle);
|
||||
free(kq);
|
||||
}
|
||||
|
@ -50,6 +50,16 @@
|
||||
HANDLE kq_events[MAXIMUM_WAIT_OBJECTS]; \
|
||||
size_t kq_nevents
|
||||
|
||||
/*
|
||||
* Hooks and prototypes
|
||||
*/
|
||||
#define kqueue_free_hook windows_kqueue_free
|
||||
void windows_kqueue_free(struct kqueue *);
|
||||
|
||||
#define kqueue_init_hook windows_kqueue_init
|
||||
int windows_kqueue_init(struct kqueue *);
|
||||
|
||||
|
||||
/* Windows does not support this attribute.
|
||||
DllMain() is the only available constructor function.
|
||||
This means the constructor must be called from within DllMain().
|
||||
|
Loading…
Reference in New Issue
Block a user