Skip to content

Commit f89f168

Browse files
committed
depends: Fix compiling libevent package on NetBSD
1 parent 1172bc4 commit f89f168

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

depends/packages/libevent.mk

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ $(package)_download_path=https://github.com/libevent/libevent/releases/download/
44
$(package)_file_name=$(package)-$($(package)_version).tar.gz
55
$(package)_sha256_hash=92e6de1be9ec176428fd2367677e61ceffc2ee1cb119035037a27d346b0403bb
66
$(package)_patches=cmake_fixups.patch
7+
$(package)_patches += netbsd_fixup.patch
78
$(package)_build_subdir=build
89

910
# When building for Windows, we set _WIN32_WINNT to target the same Windows
@@ -23,7 +24,8 @@ define $(package)_set_vars
2324
endef
2425

2526
define $(package)_preprocess_cmds
26-
patch -p1 < $($(package)_patch_dir)/cmake_fixups.patch
27+
patch -p1 < $($(package)_patch_dir)/cmake_fixups.patch && \
28+
patch -p1 < $($(package)_patch_dir)/netbsd_fixup.patch
2729
endef
2830

2931
define $(package)_config_cmds
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
Improve portability on NetBSD
2+
3+
According to GCC documentation, "the various `-std` options disable
4+
certain keywords".
5+
This change adheres to GCC's recommendation by replacing the `typeof`
6+
keyword with its alternative, `__typeof__`.
7+
8+
See https://github.com/libevent/libevent/commit/1759485e9a59147a47a674f5132fcfe764e7748c.
9+
10+
11+
--- a/kqueue.c
12+
+++ b/kqueue.c
13+
@@ -52,8 +52,8 @@
14+
* intptr_t, whereas others define it as void*. There doesn't seem to be an
15+
* easy way to tell them apart via autoconf, so we need to use OS macros. */
16+
#if defined(__NetBSD__)
17+
-#define PTR_TO_UDATA(x) ((typeof(((struct kevent *)0)->udata))(x))
18+
-#define INT_TO_UDATA(x) ((typeof(((struct kevent *)0)->udata))(intptr_t)(x))
19+
+#define PTR_TO_UDATA(x) ((__typeof__(((struct kevent *)0)->udata))(x))
20+
+#define INT_TO_UDATA(x) ((__typeof__(((struct kevent *)0)->udata))(intptr_t)(x))
21+
#elif defined(EVENT__HAVE_INTTYPES_H) && !defined(__OpenBSD__) && !defined(__FreeBSD__) && !defined(__darwin__) && !defined(__APPLE__) && !defined(__CloudABI__)
22+
#define PTR_TO_UDATA(x) ((intptr_t)(x))
23+
#define INT_TO_UDATA(x) ((intptr_t)(x))

0 commit comments

Comments
 (0)