Building a testdir on Haiku, I see this compilation error: gcc -DHAVE_CONFIG_H -DEXEEXT=\"\" -DEXEEXT=\"\" -DNO_XMALLOC -DEXEEXT=\"\" -I. -I../../gllib -I.. -DGNULIB_STRICT_CHECKING=1 -I/boot/home/config/non-packaged/include -Wall -fvisibility=hidden -g -O2 -MT nonblocking.o -MD -MP -MF $depbase.Tpo -c -o nonblocking.o ../../gllib/nonblocking.c &&\ mv -f $depbase.Tpo $depbase.Po ../../gllib/nonblocking.c:129:4: error: #error Please port nonblocking to your platform 129 | # error Please port nonblocking to your platform | ^~~~~ Makefile:12111: recipe for target 'nonblocking.o' failed make[4]: *** [nonblocking.o] Error 1
The cause is the recursive include <fcntl.h> -> <unistd.h> -> <fcntl.h>, that was introduced on 2025-02-16 and that has the effect that fcntl.h examines the value of O_NONBLOCKING before this macro has gotten its final value. This patch fixes it. 2025-03-12 Bruno Haible <br...@clisp.org> fcntl-h: Fix GNULIB_defined_O_NONBLOCK on Haiku (regr. 2025-02-16). * lib/fcntl.in.h (_@GUARD_PREFIX@_ALREADY_INCLUDING_FCNTL_H): New macro. diff --git a/lib/fcntl.in.h b/lib/fcntl.in.h index ac61c0865a..d7f551b30f 100644 --- a/lib/fcntl.in.h +++ b/lib/fcntl.in.h @@ -22,8 +22,12 @@ #endif @PRAGMA_COLUMNS@ -#if defined __need_system_fcntl_h -/* Special invocation convention. */ +#if defined __need_system_fcntl_h || defined _@GUARD_PREFIX@_ALREADY_INCLUDING_FCNTL_H +/* Special invocation convention: + - On Haiku we have a sequence of nested includes + <fcntl.h> -> <unistd.h> -> <fcntl.h> + In this situation, GNULIB_defined_O_NONBLOCK gets defined before the + system's definition of O_NONBLOCK is processed. */ /* Needed before <sys/stat.h>. May also define off_t to a 64-bit type on native Windows. */ @@ -50,6 +54,8 @@ #ifndef _@GUARD_PREFIX@_FCNTL_H +#define _@GUARD_PREFIX@_ALREADY_INCLUDING_FCNTL_H + /* Needed before <sys/stat.h>. May also define off_t to a 64-bit type on native Windows. Also defines off64_t on macOS, NetBSD, OpenBSD, MSVC, Cygwin, Haiku. */ @@ -72,6 +78,8 @@ # include <io.h> #endif +#undef _@GUARD_PREFIX@_ALREADY_INCLUDING_FCNTL_H + #ifndef _@GUARD_PREFIX@_FCNTL_H #define _@GUARD_PREFIX@_FCNTL_H