]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
Reduce risk of compilation errors within include files.
authorBruno Haible <bruno@clisp.org>
Fri, 15 Aug 2025 12:42:07 +0000 (14:42 +0200)
committerBruno Haible <bruno@clisp.org>
Fri, 15 Aug 2025 12:42:07 +0000 (14:42 +0200)
* lib/dirent.in.h: Move include <sys/stat.h> near the end of the file.
* lib/stdlib.in.h: Move include <sys/wait.h> near the end of the file.
* lib/sys_select.in.h: Move include <string.h> near the end of the file.
* lib/unistd.in.h: Add comment.

ChangeLog
lib/dirent.in.h
lib/stdlib.in.h
lib/sys_select.in.h
lib/unistd.in.h

index cf0e5f7a8e01ee48f4a1c0e28a58c6e1ca189d57..29897dc8c5735471f0aa81f6df8b60bc0c6adfae 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2025-08-15  Bruno Haible  <bruno@clisp.org>
+
+       Reduce risk of compilation errors within include files.
+       * lib/dirent.in.h: Move include <sys/stat.h> near the end of the file.
+       * lib/stdlib.in.h: Move include <sys/wait.h> near the end of the file.
+       * lib/sys_select.in.h: Move include <string.h> near the end of the file.
+       * lib/unistd.in.h: Add comment.
+
 2025-08-14  Bruno Haible  <bruno@clisp.org>
 
        utimens: Use issymlink.
index 9d3bffa97ffbef17ad323fd8d83c15c7d0bf807e..e6c59e5a41d04198115e564493764ae6c03cd077 100644 (file)
@@ -101,40 +101,6 @@ static_assert (DT_UNKNOWN != DT_FIFO && DT_UNKNOWN != DT_CHR
 /* Other optional information about a directory entry.  */
 #define _GL_DT_NOTDIR 0x100   /* Not a directory */
 
-/* Conversion between S_IF* and DT_* file types.  */
-#if ! (defined IFTODT && defined DTTOIF)
-# include <sys/stat.h>
-# ifdef S_ISWHT
-#  define _GL_DIRENT_S_ISWHT(mode) S_ISWHT(mode)
-# else
-#  define _GL_DIRENT_S_ISWHT(mode) 0
-# endif
-# ifdef S_IFWHT
-#  define _GL_DIRENT_S_IFWHT S_IFWHT
-# else
-#  define _GL_DIRENT_S_IFWHT (DT_WHT << 12) /* just a guess */
-# endif
-#endif
-/* Conversion from a 'stat' mode to a DT_* value.  */
-#ifndef IFTODT
-# define IFTODT(mode) \
-   (S_ISREG (mode) ? DT_REG : S_ISDIR (mode) ? DT_DIR \
-    : S_ISLNK (mode) ? DT_LNK : S_ISBLK (mode) ? DT_BLK \
-    : S_ISCHR (mode) ? DT_CHR : S_ISFIFO (mode) ? DT_FIFO \
-    : S_ISSOCK (mode) ? DT_SOCK \
-    : _GL_DIRENT_S_ISWHT (mode) ? DT_WHT : DT_UNKNOWN)
-#endif
-/* Conversion from a DT_* value to a 'stat' mode.  */
-#ifndef DTTOIF
-# define DTTOIF(dirtype) \
-   ((dirtype) == DT_REG ? S_IFREG : (dirtype) == DT_DIR ? S_IFDIR \
-    : (dirtype) == DT_LNK ? S_IFLNK : (dirtype) == DT_BLK ? S_IFBLK \
-    : (dirtype) == DT_CHR ? S_IFCHR :  dirtype == DT_FIFO ? S_IFIFO \
-    : (dirtype) == DT_SOCK ? S_IFSOCK \
-    : (dirtype) == DT_WHT ? _GL_DIRENT_S_IFWHT \
-    : (dirtype) << 12 /* just a guess */)
-#endif
-
 #if !@DIR_HAS_FD_MEMBER@
 # if !GNULIB_defined_DIR
 /* struct gl_directory is a type with a field 'int fd_to_close'.
@@ -426,5 +392,44 @@ _GL_WARN_ON_USE (alphasort, "alphasort is unportable - "
 #endif
 
 
+/* Includes that provide only macros that don't need to be overridden.
+   (Includes that are needed for type definitions and function declarations
+   have their place above, before the function overrides.)  */
+
+/* Conversion between S_IF* and DT_* file types.  */
+#if ! (defined IFTODT && defined DTTOIF)
+# include <sys/stat.h>
+# ifdef S_ISWHT
+#  define _GL_DIRENT_S_ISWHT(mode) S_ISWHT(mode)
+# else
+#  define _GL_DIRENT_S_ISWHT(mode) 0
+# endif
+# ifdef S_IFWHT
+#  define _GL_DIRENT_S_IFWHT S_IFWHT
+# else
+#  define _GL_DIRENT_S_IFWHT (DT_WHT << 12) /* just a guess */
+# endif
+#endif
+/* Conversion from a 'stat' mode to a DT_* value.  */
+#ifndef IFTODT
+# define IFTODT(mode) \
+   (S_ISREG (mode) ? DT_REG : S_ISDIR (mode) ? DT_DIR \
+    : S_ISLNK (mode) ? DT_LNK : S_ISBLK (mode) ? DT_BLK \
+    : S_ISCHR (mode) ? DT_CHR : S_ISFIFO (mode) ? DT_FIFO \
+    : S_ISSOCK (mode) ? DT_SOCK \
+    : _GL_DIRENT_S_ISWHT (mode) ? DT_WHT : DT_UNKNOWN)
+#endif
+/* Conversion from a DT_* value to a 'stat' mode.  */
+#ifndef DTTOIF
+# define DTTOIF(dirtype) \
+   ((dirtype) == DT_REG ? S_IFREG : (dirtype) == DT_DIR ? S_IFDIR \
+    : (dirtype) == DT_LNK ? S_IFLNK : (dirtype) == DT_BLK ? S_IFBLK \
+    : (dirtype) == DT_CHR ? S_IFCHR :  dirtype == DT_FIFO ? S_IFIFO \
+    : (dirtype) == DT_SOCK ? S_IFSOCK \
+    : (dirtype) == DT_WHT ? _GL_DIRENT_S_IFWHT \
+    : (dirtype) << 12 /* just a guess */)
+#endif
+
+
 #endif /* _@GUARD_PREFIX@_DIRENT_H */
 #endif /* _@GUARD_PREFIX@_DIRENT_H */
index 1342db4877245934ec5276317382e91fc0ce8c14..d74db3c7c7352142be81e4d245ad326993c1009e 100644 (file)
 /* NetBSD 5.0 mis-defines NULL.  */
 #include <stddef.h>
 
-/* MirBSD 10 defines WEXITSTATUS in <sys/wait.h>, not in <stdlib.h>.
-   glibc 2.41 defines WCOREDUMP in <sys/wait.h>, not in <stdlib.h>.  */
-#if @GNULIB_SYSTEM_POSIX@ && !(defined WEXITSTATUS && defined WCOREDUMP)
-# include <sys/wait.h>
-#endif
-
 /* Solaris declares getloadavg() in <sys/loadavg.h>.  */
 #if (@GNULIB_GETLOADAVG@ || defined GNULIB_POSIXCHECK) && @HAVE_SYS_LOADAVG_H@
 /* OpenIndiana has a bug: <sys/time.h> must be included before
@@ -2027,6 +2021,18 @@ _GL_CXXALIASWARN (wctomb);
 
 _GL_INLINE_HEADER_END
 
+
+/* Includes that provide only macros that don't need to be overridden.
+   (Includes that are needed for type definitions and function declarations
+   have their place above, before the function overrides.)  */
+
+/* MirBSD 10 defines WEXITSTATUS in <sys/wait.h>, not in <stdlib.h>.
+   glibc 2.41 defines WCOREDUMP in <sys/wait.h>, not in <stdlib.h>.  */
+#if @GNULIB_SYSTEM_POSIX@ && !(defined WEXITSTATUS && defined WCOREDUMP)
+# include <sys/wait.h>
+#endif
+
+
 #endif /* _@GUARD_PREFIX@_STDLIB_H */
 #endif /* _@GUARD_PREFIX@_STDLIB_H */
 #endif
index a06725020d2ff94a49d94695872ce83affba03ff..c10f8f9de739f9f9496a1b2fc370233dbe96547b 100644 (file)
 #  include <sys/time.h>
 # endif
 
-/* On AIX 7 and Solaris 10, <sys/select.h> provides an FD_ZERO implementation
-   that relies on memset(), but without including <string.h>.
-   But in any case avoid namespace pollution on glibc systems.  */
-# if (defined __OpenBSD__ || defined _AIX || defined __sun || defined __osf__ || defined __BEOS__) \
-     && ! defined __GLIBC__
-#  include <string.h>
-# endif
-
 /* The include_next requires a split double-inclusion guard.  */
 # @INCLUDE_NEXT@ @NEXT_SYS_SELECT_H@
 
@@ -352,5 +344,20 @@ _GL_WARN_ON_USE (select, "select is not always POSIX compliant - "
 
 
 #endif /* _@GUARD_PREFIX@_SYS_SELECT_H */
+
+
+/* Includes that provide only macros that don't need to be overridden.
+   (Includes that are needed for type definitions and function declarations
+   have their place above, before the function overrides.)  */
+
+/* On AIX 7 and Solaris 10, <sys/select.h> provides an FD_ZERO implementation
+   that relies on memset(), but without including <string.h>.
+   But in any case avoid namespace pollution on glibc systems.  */
+# if (defined __OpenBSD__ || defined _AIX || defined __sun || defined __osf__ || defined __BEOS__) \
+     && ! defined __GLIBC__
+#  include <string.h>
+# endif
+
+
 #endif /* _@GUARD_PREFIX@_SYS_SELECT_H */
 #endif /* OSF/1 */
index 0cf272802009a9e57c8ea399d89b4a2b8f539fcb..ea221481f878a6aa8aadc81f27215b2b56308e5b 100644 (file)
@@ -2490,12 +2490,18 @@ _GL_CXXALIASWARN (write);
 
 _GL_INLINE_HEADER_END
 
+
+/* Includes that provide only macros that don't need to be overridden.
+   (Includes that are needed for type definitions and function declarations
+   have their place above, before the function overrides.)  */
+
 /* FreeBSD 14.0, NetBSD 10.0, OpenBSD 7.5, Solaris 11.4, and glibc 2.41
    do not define O_CLOEXEC in <unistd.h>.  */
 #if ! defined O_CLOEXEC
 # include <fcntl.h>
 #endif
 
+
 #endif /* _@GUARD_PREFIX@_UNISTD_H */
 #endif /* _GL_INCLUDING_UNISTD_H */
 #endif /* _@GUARD_PREFIX@_UNISTD_H */