From 6f2dbaab5f0f63e655fd581d16eead9aa4b0b0f7 Mon Sep 17 00:00:00 2001 From: "tree-sitter-ci-bot[bot]" <180118140+tree-sitter-ci-bot[bot]@users.noreply.github.com> Date: Sun, 2 Mar 2025 23:46:23 +0100 Subject: [PATCH] build: do not define _POSIX_C_SOURCE on NetBSD (#4196) It leads to missing symbols, see #4180. (cherry picked from commit 2bf04d1f045f27a265ed1b1916e5eef929c13bae) --------- Co-authored-by: Thomas Klausner --- lib/src/portable/endian.h | 6 +++++- lib/src/query.c | 9 +++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/src/portable/endian.h b/lib/src/portable/endian.h index 6aa4438d..51defc5e 100644 --- a/lib/src/portable/endian.h +++ b/lib/src/portable/endian.h @@ -18,16 +18,20 @@ #if defined(HAVE_ENDIAN_H) || \ defined(__linux__) || \ defined(__GNU__) || \ + defined(__NetBSD__) || \ defined(__OpenBSD__) || \ defined(__CYGWIN__) || \ defined(__MSYS__) || \ defined(__EMSCRIPTEN__) +#if defined(__NetBSD__) +#define _NETBSD_SOURCE 1 +#endif + # include #elif defined(HAVE_SYS_ENDIAN_H) || \ defined(__FreeBSD__) || \ - defined(__NetBSD__) || \ defined(__DragonFly__) # include diff --git a/lib/src/query.c b/lib/src/query.c index 05eddef5..eb4e906c 100644 --- a/lib/src/query.c +++ b/lib/src/query.c @@ -1,3 +1,12 @@ +/* + * On NetBSD, defining standard requirements like this removes symbols + * from the namespace; however, we need non-standard symbols for + * endian.h. + */ +#if defined(__NetBSD__) && defined(_POSIX_C_SOURCE) +#undef _POSIX_C_SOURCE +#endif + #include "tree_sitter/api.h" #include "./alloc.h" #include "./array.h"