/
darwin_kqueue.c
executable file
·64 lines (55 loc) · 1.18 KB
/
darwin_kqueue.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*
* core: darwin_kqueue.c
* Copyright (c) 2012 Christina Brooks
*
* Something like BSD kernel queues.
*/
#include <stdio.h>
#include <sys/types.h>
#include <sys/event.h>
#include <sys/time.h>
#include "OSLog.h"
typedef union epoll_data {
void *ptr;
int fd;
uint32_t u32;
uint64_t u64;
} epoll_data_t;
struct epoll_event {
uint32_t events; /* Epoll events */
epoll_data_t data; /* User data variable */
};
int epoll_create$LINUX(int size);
int epoll_wait$LINUX(int epfd, struct epoll_event *events, int maxevents, int timeout);
int epoll_ctl$LINUX(int epfd, int op, int fd, struct epoll_event *event);
int
kqueue(void)
{
/*
The kqueue identifier is opaque, so lets just return
the epoll's descriptor.
*/
return epoll_create$LINUX(0);
}
int
kevent(int kq,
const struct kevent *changelist,
int nchanges,
struct kevent *eventlist,
int nevents,
const struct timespec *timeout)
{
return -1;
}
int
kevent64(int kq,
const struct kevent64_s *changelist,
int nchanges,
struct kevent64_s *eventlist,
int nevents,
unsigned int flags,
const struct timespec *timeout)
{
OSHalt("kevent64: why would you do this?");
}
// newline! \n