Added libc code
This commit is contained in:
48
include/sys/event.h
Normal file
48
include/sys/event.h
Normal file
@@ -0,0 +1,48 @@
|
||||
// Zak's kqueue implementation
|
||||
#ifndef SYS_EVENT_H
|
||||
#define SYS_EVENT_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
// The kevent structure is used for waiting/receiving notifications.
|
||||
struct kevent {
|
||||
uintptr_t ident;
|
||||
int16_t filter;
|
||||
uint16_t flags;
|
||||
uint32_t fflags;
|
||||
int64_t data;
|
||||
void* udata;
|
||||
uint64_t ext[4];
|
||||
};
|
||||
|
||||
// kqueue1 is the kqueue system call with a flags argument,
|
||||
// as defined on NetBSD & OpenBSD.
|
||||
int kqueue1(int flags);
|
||||
|
||||
// kqueue() without flags is equivalent to kqueue1(0)
|
||||
#define kqueue() kqueue1(0)
|
||||
|
||||
// On FreeBSD, kqueue1 is also known as kqueuex
|
||||
#define kqueuex(flags) kqueue1(flags)
|
||||
|
||||
// After creating a kqueue, kevent is the main syscall used.
|
||||
// This accepts a list of changes and can receive multiple events.
|
||||
int kevent(int queue, const struct kevent* changes, int nch, struct kevent* events, int nev, void* todo_timeout);
|
||||
|
||||
// The EV_SET() macro is for initialising a struct kevent*
|
||||
#define EV_SET(ev,idn,flt,flg,ffl,dat,udt) \
|
||||
do { \
|
||||
(ev)->ident = idn; \
|
||||
(ev)->filter = flt; \
|
||||
(ev)->flags = flg; \
|
||||
(ev)->fflags = ffl; \
|
||||
(ev)->data = dat; \
|
||||
(ev)->udata = udt; \
|
||||
(ev)->ext[0] = 0; \
|
||||
(ev)->ext[1] = 0; \
|
||||
(ev)->ext[2] = 0; \
|
||||
(ev)->ext[3] = 0; \
|
||||
} while(0)
|
||||
|
||||
// From ifndef at top of file:
|
||||
#endif
|
Reference in New Issue
Block a user