Changeset View
Changeset View
Standalone View
Standalone View
sys/sys/event.h
Show First 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | |||||
#define EVFILT_PROCDESC (-8) /* attached to process descriptors */ | #define EVFILT_PROCDESC (-8) /* attached to process descriptors */ | ||||
#define EVFILT_FS (-9) /* filesystem events */ | #define EVFILT_FS (-9) /* filesystem events */ | ||||
#define EVFILT_LIO (-10) /* attached to lio requests */ | #define EVFILT_LIO (-10) /* attached to lio requests */ | ||||
#define EVFILT_USER (-11) /* User events */ | #define EVFILT_USER (-11) /* User events */ | ||||
#define EVFILT_SENDFILE (-12) /* attached to sendfile requests */ | #define EVFILT_SENDFILE (-12) /* attached to sendfile requests */ | ||||
#define EVFILT_EMPTY (-13) /* empty send socket buf */ | #define EVFILT_EMPTY (-13) /* empty send socket buf */ | ||||
#define EVFILT_SYSCOUNT 13 | #define EVFILT_SYSCOUNT 13 | ||||
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L | |||||
dab: I could have done this as just a straight replacement for the old definition as from what I… | |||||
Done Inline ActionsSupporting pre-C99 here is not immediately unreasonable, since this file is included in user code. Apart from that, standard C++ does not support compound literals, so using them may cause a warning. Both GCC and Clang support compound literals in C++ as an extension, but with different semantics if a pointer is taken to one (which does not happen here). There should be a check defined(__STDC_VERSION__) so that compiling C++ code with -Wundef does not generate a warning. jilles: Supporting pre-C99 here is not immediately unreasonable, since this file is included in user… | |||||
#define EV_SET(kevp_, a, b, c, d, e, f) do { \ | #define EV_SET(kevp_, a, b, c, d, e, f) do { \ | ||||
*(kevp_) = (struct kevent){ \ | |||||
.ident = (a), \ | |||||
.filter = (b), \ | |||||
.flags = (c), \ | |||||
.fflags = (d), \ | |||||
.data = (e), \ | |||||
.udata = (f), \ | |||||
.ext[0] = 0, \ | |||||
.ext[1] = 0, \ | |||||
.ext[2] = 0, \ | |||||
.ext[3] = 0, \ | |||||
}; \ | |||||
} while(0) | |||||
#else /* Pre-C99 */ | |||||
jillesUnsubmitted Not Done Inline ActionsPre-C99 or C++ jilles: Pre-C99 or C++ | |||||
/* The definition of the local variable kevp could possibly conflict | |||||
* with a user-defined value passed in parameters a-f. | |||||
*/ | |||||
#define EV_SET(kevp_, a, b, c, d, e, f) do { \ | |||||
struct kevent *kevp = (kevp_); \ | struct kevent *kevp = (kevp_); \ | ||||
(kevp)->ident = (a); \ | (kevp)->ident = (a); \ | ||||
(kevp)->filter = (b); \ | (kevp)->filter = (b); \ | ||||
(kevp)->flags = (c); \ | (kevp)->flags = (c); \ | ||||
(kevp)->fflags = (d); \ | (kevp)->fflags = (d); \ | ||||
(kevp)->data = (e); \ | (kevp)->data = (e); \ | ||||
(kevp)->udata = (f); \ | (kevp)->udata = (f); \ | ||||
(kevp)->ext[0] = 0; \ | (kevp)->ext[0] = 0; \ | ||||
(kevp)->ext[1] = 0; \ | (kevp)->ext[1] = 0; \ | ||||
(kevp)->ext[2] = 0; \ | (kevp)->ext[2] = 0; \ | ||||
(kevp)->ext[3] = 0; \ | (kevp)->ext[3] = 0; \ | ||||
} while(0) | } while(0) | ||||
#endif | |||||
struct kevent { | struct kevent { | ||||
__uintptr_t ident; /* identifier for this event */ | __uintptr_t ident; /* identifier for this event */ | ||||
short filter; /* filter for event */ | short filter; /* filter for event */ | ||||
unsigned short flags; | unsigned short flags; | ||||
unsigned int fflags; | unsigned int fflags; | ||||
__int64_t data; | __int64_t data; | ||||
void *udata; /* opaque user data identifier */ | void *udata; /* opaque user data identifier */ | ||||
▲ Show 20 Lines • Show All 281 Lines • Show Last 20 Lines |
I could have done this as just a straight replacement for the old definition as from what I understand all platforms compile with at least C99 support. However, I decided to take this approach in case someone is still building with a pre-C99 compiler. I saw several other places in the code base that check for C99/pre-C99.