[PATCH] unistd: use __USE_XOPEN2K24 for existing POSIX.1-2024 interfaces

Collin Funk collin.funk1@gmail.com
Sat Feb 21 04:49:37 GMT 2026


* posix/unistd.h (SEEK_DATA, SEEK_HOLE, pipe2, dup2, getresgid)
(getresuid, setresgid, setresuid, _Fork): Make visible when
__USE_XOPEN2K24 is defined, which is also defined when __USE_GNU is
defined.
(getentropy): Also define when __USE_XOPEN2K24 is defined.
* conform/data/unistd.h-data: Add checks for the prototypes, although
conform has not yet been adjusted to support POSIX.1-2024.
---
 conform/data/unistd.h-data | 25 +++++++++++++++++++++++++
 posix/unistd.h             | 12 ++++++------
 2 files changed, 31 insertions(+), 6 deletions(-)

diff --git a/conform/data/unistd.h-data b/conform/data/unistd.h-data
index b4531868fd..15bff17be5 100644
--- a/conform/data/unistd.h-data
+++ b/conform/data/unistd.h-data
@@ -171,6 +171,11 @@ constant SEEK_SET
 constant SEEK_CUR
 constant SEEK_END
 
+#ifdef POSIX24
+constant SEEK_DATA
+constant SEEK_HOLE
+#endif
+
 #ifndef POSIX
 constant _SC_2_C_BIND
 #endif
@@ -446,6 +451,9 @@ allow cuserid
 #endif
 function int dup (int)
 function int dup2 (int, int)
+#ifdef POSIX24
+function int dup3 (int, int, int)
+#endif
 function int execl (const char*, const char*, ...)
 function int execle (const char*, const char*, ...)
 function int execlp (const char*, const char*, ...)
@@ -468,6 +476,9 @@ function int fchdir (int)
 #if !defined XPG4 && !defined XPG42
 function int fdatasync (int)
 #endif
+#ifdef POSIX24
+function int _Fork (void)
+#endif
 # if defined XOPEN2K8 || defined POSIX2008
 function int fexecve (int, char *const[], char *const[])
 # endif
@@ -483,6 +494,9 @@ function int getdtablesize (void)
 #endif
 function gid_t getegid (void)
 function uid_t geteuid (void)
+#ifdef POSIX24
+function int getentropy (void*, size_t)
+#endif
 function gid_t getgid (void)
 function int getgroups (int, gid_t[])
 #if !defined XPG4 && !defined POSIX && !defined POSIX2008
@@ -508,6 +522,10 @@ function pid_t getpgid (pid_t)
 function pid_t getpgrp (void)
 function pid_t getpid (void)
 function pid_t getppid (void)
+#ifdef POSIX24
+function int getresgid (gid_t*, gid_t*, gid_t*)
+function int getresuid (uid_t*, uid_t*, uid_t*)
+#endif
 #if !defined XPG4 && !defined POSIX
 function pid_t getsid (pid_t)
 #endif
@@ -533,6 +551,9 @@ function int nice (int)
 function {long int} pathconf (const char*, int)
 function int pause (void)
 function int pipe (int[2])
+#ifdef POSIX24
+function int pipe2 (int[2], int)
+#endif
 #if !defined POSIX && !defined XPG4 && !defined XPG42
 function ssize_t pread (int, void*, size_t, off_t)
 #endif
@@ -564,6 +585,10 @@ function pid_t setpgrp (void)
 function int setregid (gid_t, gid_t)
 function int setreuid (uid_t, uid_t)
 # endif
+#ifdef POSIX24
+function int setresgid (gid_t, gid_t, gid_t)
+function int setresuid (uid_t, uid_t, uid_t)
+#endif
 function pid_t setsid (void)
 function int setuid (uid_t)
 function {unsigned int} sleep (unsigned int)
diff --git a/posix/unistd.h b/posix/unistd.h
index 06a6a88b52..6bfc5a2d29 100644
--- a/posix/unistd.h
+++ b/posix/unistd.h
@@ -316,7 +316,7 @@ extern int faccessat (int __fd, const char *__file, int __type, int __flag)
 # define SEEK_SET	0	/* Seek from beginning of file.  */
 # define SEEK_CUR	1	/* Seek from current position.  */
 # define SEEK_END	2	/* Seek from end of file.  */
-# ifdef __USE_GNU
+# ifdef __USE_XOPEN2K24
 #  define SEEK_DATA	3	/* Seek to next data.  */
 #  define SEEK_HOLE	4	/* Seek to next hole.  */
 # endif
@@ -436,7 +436,7 @@ extern ssize_t pwrite64 (int __fd, const void *__buf, size_t __n,
    Returns 0 if successful, -1 if not.  */
 extern int pipe (int __pipedes[2]) __THROW __wur;
 
-#ifdef __USE_GNU
+#ifdef __USE_XOPEN2K24
 /* Same as pipe but apply flags passed in FLAGS to the new file
    descriptors.  */
 extern int pipe2 (int __pipedes[2], int __flags) __THROW __wur;
@@ -554,7 +554,7 @@ extern int dup (int __fd) __THROW __wur;
 /* Duplicate FD to FD2, closing FD2 and making it open on the same file.  */
 extern int dup2 (int __fd, int __fd2) __THROW;
 
-#ifdef __USE_GNU
+#ifdef __USE_XOPEN2K24
 /* Duplicate FD to FD2, closing FD2 and making it open on the same
    file while setting flags according to FLAGS.  */
 extern int dup3 (int __fd, int __fd2, int __flags) __THROW;
@@ -749,7 +749,7 @@ extern int setregid (__gid_t __rgid, __gid_t __egid) __THROW __wur;
 extern int setegid (__gid_t __gid) __THROW __wur;
 #endif /* Use POSIX.1-2001.  */
 
-#ifdef __USE_GNU
+#ifdef __USE_XOPEN2K24
 /* Fetch the real user ID, effective user ID, and saved-set user ID,
    of the calling process.  */
 extern int getresuid (__uid_t *__ruid, __uid_t *__euid, __uid_t *__suid)
@@ -786,7 +786,7 @@ extern __pid_t fork (void) __THROWNL;
 extern __pid_t vfork (void) __THROW;
 #endif /* Use misc or XPG < 7. */
 
-#ifdef __USE_GNU
+#ifdef __USE_XOPEN2K24
 /* This is similar to fork, however it does not run the atfork handlers
    neither reinitialize any internal locks in multithread case.
    Different than fork, _Fork is async-signal-safe.  */
@@ -1195,7 +1195,7 @@ extern int pthread_atfork (void (*__prepare) (void),
 			   void (*__child) (void)) __THROW;
 #endif
 
-#ifdef __USE_MISC
+#if defined __USE_MISC || defined __USE_XOPEN2K24
 /* Write LENGTH bytes of randomness starting at BUFFER.  Return 0 on
    success or -1 on error.  */
 int getentropy (void *__buffer, size_t __length) __wur
-- 
2.53.0



More information about the Libc-alpha mailing list