]> granicus.if.org Git - libevent/commitdiff
Fix compat with NetBSD >= 10
authorKamil Rytarowski <n54@gmx.com>
Thu, 3 Oct 2019 23:26:47 +0000 (01:26 +0200)
committerKamil Rytarowski <n54@gmx.com>
Thu, 3 Oct 2019 23:30:39 +0000 (01:30 +0200)
kevent::udata was switched from intptr_t to void*.

Handle both cases with the GCC extension typeof().

kqueue.c

index d08f512ce4b68debaff086929f9d5077cc5d725e..dfd7751d649711d4e6f19cf5235cdecf1faeaee9 100644 (file)
--- a/kqueue.c
+++ b/kqueue.c
 /* Some platforms apparently define the udata field of struct kevent as
  * intptr_t, whereas others define it as void*.  There doesn't seem to be an
  * easy way to tell them apart via autoconf, so we need to use OS macros. */
-#if defined(EVENT__HAVE_INTTYPES_H) && !defined(__OpenBSD__) && !defined(__FreeBSD__) && !defined(__darwin__) && !defined(__APPLE__) && !defined(__CloudABI__)
+#if defined(__NetBSD__)
+#define PTR_TO_UDATA(x) ((typeof(((struct kevent *)0)->udata))(x))
+#define INT_TO_UDATA(x) ((typeof(((struct kevent *)0)->udata))(intptr_t)(x))
+#elif defined(EVENT__HAVE_INTTYPES_H) && !defined(__OpenBSD__) && !defined(__FreeBSD__) && !defined(__darwin__) && !defined(__APPLE__) && !defined(__CloudABI__)
 #define PTR_TO_UDATA(x)        ((intptr_t)(x))
 #define INT_TO_UDATA(x) ((intptr_t)(x))
 #else