From: Collin Funk Date: Sun, 16 Feb 2025 20:23:57 +0000 (-0800) Subject: unistd-h: Make sure O_CLOEXEC is defined. X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=10331a8ba5e9548671907a09eb6d5d7260543c39;p=gnulib.git unistd-h: Make sure O_CLOEXEC is defined. * modules/unistd-h (Depends-on): Add fcntl-h. * lib/unistd.in.h: Include fcntl.h if inclusion of unistd.h does not define O_CLOEXEC. * doc/posix-headers/unistd.texi: Document the platforms that do not define O_CLOEXEC in unistd.h. --- diff --git a/ChangeLog b/ChangeLog index 1fa41775dc..de21277abe 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2025-02-16 Collin Funk + + unistd-h: Make sure O_CLOEXEC is defined. + * modules/unistd-h (Depends-on): Add fcntl-h. + * lib/unistd.in.h: Include fcntl.h if inclusion of unistd.h does not + define O_CLOEXEC. + * doc/posix-headers/unistd.texi: Document the platforms that do not + define O_CLOEXEC in unistd.h. + 2025-02-16 Bruno Haible strncasecmp: Add tests. diff --git a/doc/posix-headers/unistd.texi b/doc/posix-headers/unistd.texi index 70c9a87154..4481bcfc1a 100644 --- a/doc/posix-headers/unistd.texi +++ b/doc/posix-headers/unistd.texi @@ -23,6 +23,9 @@ OS/2 EMX, mingw. @item The @code{_exit} function is not declared in this file on some platforms: mingw. +@item +This header file does not define @code{O_CLOEXEC} on some platforms: +glibc 2.41, FreeBSD 14.0, NetBSD 10.0, OpenBSD 7.5, Solaris 11.4, Cygwin 3.5, mingw, MSVC 14. @item Some platforms provide a @code{NULL} macro that cannot be used in arbitrary diff --git a/lib/unistd.in.h b/lib/unistd.in.h index 3f96e10d7e..acabdf8c68 100644 --- a/lib/unistd.in.h +++ b/lib/unistd.in.h @@ -95,12 +95,15 @@ # include #endif +/* FreeBSD 14.0, NetBSD 10.0, OpenBSD 7.5, Solaris 11.4, and glibc 2.41 + do not define O_CLOEXEC in . */ /* Cygwin 1.7.1 and Android 4.3 declare unlinkat in , not in . */ /* But avoid namespace pollution on glibc systems. */ -#if (@GNULIB_UNLINKAT@ || defined GNULIB_POSIXCHECK) \ - && (defined __CYGWIN__ || defined __ANDROID__) \ - && ! defined __GLIBC__ +#if ! defined O_CLOEXEC \ + || ((@GNULIB_UNLINKAT@ || defined GNULIB_POSIXCHECK) \ + && (defined __CYGWIN__ || defined __ANDROID__) \ + && ! defined __GLIBC__) # include #endif diff --git a/modules/unistd-h b/modules/unistd-h index af7fda5944..1a7376efdb 100644 --- a/modules/unistd-h +++ b/modules/unistd-h @@ -15,6 +15,7 @@ include_next snippet/arg-nonnull snippet/c++defs snippet/warn-on-use +fcntl-h ssize_t stddef-h sys_types-h