@c Which is which?
@item MAP_ANONYMOUS
@itemx MAP_ANON
+@standards{POSIX.1-2024, sys/mman.h}
+@standardsx{MAP_ANON, POSIX.1-2024, sys/mman.h}
This flag tells the system to create an anonymous mapping, not connected
to a file. @var{filedes} and @var{offset} are ignored, and the region is
initialized with zeros.
@end deftypefun
@deftypefun int dup3 (int @var{old}, int @var{new}, int @var{flags})
-@standards{Linux, unistd.h}
+@standards{POSIX.1-2024, unistd.h}
@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
This function is the same as @code{dup2} but creates the new
descriptor as if it had been opened with flags @var{flags}. The only
allowed flag is @code{O_CLOEXEC}.
+
+This function was originally a Linux extension, but was added in
+POSIX.1-2024.
@end deftypefun
@deftypevr Macro int F_DUPFD
@end deftypefun
@deftypefun {void *} reallocarray (void *@var{ptr}, size_t @var{nmemb}, size_t @var{size})
-@standards{BSD, malloc.h}
-@standards{BSD, stdlib.h}
+@standards{POSIX.1-2024, malloc.h}
+@standards{POSIX.1-2024, stdlib.h}
@safety{@prelim{}@mtsafe{}@asunsafe{@asulock{}}@acunsafe{@aculock{} @acsfd{} @acsmem{}}}
The @code{reallocarray} function changes the size of the block whose address
@code{reallocarray} should be used instead of @code{realloc} when the new size
of the allocated block is the result of a multiplication that might overflow.
-@strong{Portability Note:} This function is not part of any standard. It was
-first introduced in OpenBSD 5.6.
+This function was originally derived from OpenBSD 5.6, but was added in
+POSIX.1-2024.
@end deftypefun
Like @code{malloc}, @code{realloc} and @code{reallocarray} may return a null
selection of the user.
@Theglibc{} provides two different sets of functions to support
-message translation. The problem is that neither of the interfaces is
-officially defined by the POSIX standard. The @code{catgets} family of
-functions is defined in the X/Open standard but this is derived from
-industry decisions and therefore not necessarily based on reasonable
-decisions.
+message translation. The @code{catgets} family of functions were
+previously the only family defined in the X/Open standard but they were
+derived from industry decisions and therefore not necessarily based on
+reasonable decisions. However, the preferable @code{gettext} family of
+functions was standardized in POSIX-1.2024.
As mentioned above, the message catalog handling provides easy
extendability by using external data files which contain the message
@file{libintl.a} (or accordingly different for shared libraries).
@deftypefun {char *} gettext (const char *@var{msgid})
-@standards{GNU, libintl.h}
+@standards{POSIX-1.2024, libintl.h}
@safety{@prelim{}@mtsafe{@mtsenv{}}@asunsafe{@asucorrupt{} @ascuheap{} @asulock{} @ascudlopen{}}@acunsafe{@acucorrupt{} @aculock{} @acsfd{} @acsmem{}}}
@c Wrapper for dcgettext.
The @code{gettext} function searches the currently selected message
information.
@deftypefun {char *} dgettext (const char *@var{domainname}, const char *@var{msgid})
-@standards{GNU, libintl.h}
+@standards{POSIX-1.2024, libintl.h}
@safety{@prelim{}@mtsafe{@mtsenv{}}@asunsafe{@asucorrupt{} @ascuheap{} @asulock{} @ascudlopen{}}@acunsafe{@acucorrupt{} @aculock{} @acsfd{} @acsmem{}}}
@c Wrapper for dcgettext.
The @code{dgettext} function acts just like the @code{gettext}
@end deftypefun
@deftypefun {char *} dcgettext (const char *@var{domainname}, const char *@var{msgid}, int @var{category})
-@standards{GNU, libintl.h}
+@standards{POSIX-1.2024, libintl.h}
@safety{@prelim{}@mtsafe{@mtsenv{}}@asunsafe{@asucorrupt{} @ascuheap{} @asulock{} @ascudlopen{}}@acunsafe{@acucorrupt{} @aculock{} @acsfd{} @acsmem{}}}
@c dcgettext @mtsenv @asucorrupt @ascuheap @asulock @ascudlopen @acucorrupt @aculock @acsfd @acsmem
@c dcigettext @mtsenv @asucorrupt @ascuheap @asulock @ascudlopen @acucorrupt @aculock @acsfd @acsmem
function.
@deftypefun {char *} textdomain (const char *@var{domainname})
-@standards{GNU, libintl.h}
+@standards{POSIX-1.2024, libintl.h}
@safety{@prelim{}@mtsafe{}@asunsafe{@asulock{} @ascuheap{}}@acunsafe{@aculock{} @acsmem{}}}
@c textdomain @asulock @ascuheap @aculock @acsmem
@c libc_rwlock_wrlock @asulock @aculock
@end deftypefun
@deftypefun {char *} bindtextdomain (const char *@var{domainname}, const char *@var{dirname})
-@standards{GNU, libintl.h}
+@standards{POSIX-1.2024, libintl.h}
@safety{@prelim{}@mtsafe{}@asunsafe{@ascuheap{}}@acunsafe{@acsmem{}}}
@c bindtextdomain @ascuheap @acsmem
@c set_binding_values @ascuheap @acsmem
purpose.
@deftypefun {char *} ngettext (const char *@var{msgid1}, const char *@var{msgid2}, unsigned long int @var{n})
-@standards{GNU, libintl.h}
+@standards{POSIX-1.2024, libintl.h}
@safety{@prelim{}@mtsafe{@mtsenv{}}@asunsafe{@asucorrupt{} @ascuheap{} @asulock{} @ascudlopen{}}@acunsafe{@acucorrupt{} @aculock{} @acsfd{} @acsmem{}}}
@c Wrapper for dcngettext.
The @code{ngettext} function is similar to the @code{gettext} function
@end deftypefun
@deftypefun {char *} dngettext (const char *@var{domain}, const char *@var{msgid1}, const char *@var{msgid2}, unsigned long int @var{n})
-@standards{GNU, libintl.h}
+@standards{POSIX-1.2024, libintl.h}
@safety{@prelim{}@mtsafe{@mtsenv{}}@asunsafe{@asucorrupt{} @ascuheap{} @asulock{} @ascudlopen{}}@acunsafe{@acucorrupt{} @aculock{} @acsfd{} @acsmem{}}}
@c Wrapper for dcngettext.
The @code{dngettext} is similar to the @code{dgettext} function in the
@end deftypefun
@deftypefun {char *} dcngettext (const char *@var{domain}, const char *@var{msgid1}, const char *@var{msgid2}, unsigned long int @var{n}, int @var{category})
-@standards{GNU, libintl.h}
+@standards{POSIX-1.2024, libintl.h}
@safety{@prelim{}@mtsafe{@mtsenv{}}@asunsafe{@asucorrupt{} @ascuheap{} @asulock{} @ascudlopen{}}@acunsafe{@acucorrupt{} @aculock{} @acsfd{} @acsmem{}}}
@c Wrapper for dcigettext.
The @code{dcngettext} is similar to the @code{dcgettext} function in the
recommended that all @var{msgid}s be US-ASCII strings.
@deftypefun {char *} bind_textdomain_codeset (const char *@var{domainname}, const char *@var{codeset})
-@standards{GNU, libintl.h}
+@standards{POSIX-1.2024, libintl.h}
@safety{@prelim{}@mtsafe{}@asunsafe{@ascuheap{}}@acunsafe{@acsmem{}}}
@c bind_textdomain_codeset @ascuheap @acsmem
@c set_binding_values dup @ascuheap @acsmem
would match the string @samp{foobar/frobozz}.
@item FNM_CASEFOLD
-@standards{GNU, fnmatch.h}
+@standards{POSIX.1-2024, fnmatch.h}
Ignore case in comparing @var{string} to @var{pattern}.
+This macro was originally a GNU extension, but was added in
+POSIX.1-2024.
+
@item FNM_EXTMATCH
@standards{GNU, fnmatch.h}
@cindex Korn Shell
@end itemize
@deftypefun pid_t _Fork (void)
-@standards{GNU, unistd.h}
+@standards{POSIX.1-2024, unistd.h}
@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
The @code{_Fork} function is similar to @code{fork}, but it does not invoke
any callbacks registered with @code{pthread_atfork}, nor does it reset
@code{dup2} or @code{execve}.
The @code{_Fork} function is an async-signal-safe replacement of @code{fork}.
-It is a GNU extension.
+This function was originally a GNU extension, but was added in
+POSIX.1-2024.
@end deftypefun
@deftypefun pid_t vfork (void)
@end deftypefn
@deftypefn Macro int WCOREDUMP (int @var{status})
-@standards{BSD, sys/wait.h}
+@standards{POSIX.1-2024, sys/wait.h}
@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
This macro returns a nonzero value if the child process terminated
and produced a core dump.
+
+This macro was originally a BSD extension, but was added in
+POSIX.1-2024.
@end deftypefn
@deftypefn Macro int WIFSTOPPED (int @var{status})
@end deftypevr
@deftypevr Macro int SIGWINCH
-@standards{BSD, signal.h}
+@standards{POSIX.1-2024, signal.h}
Window size change. This is generated on some systems (including GNU)
when the terminal driver's record of the number of rows and columns on
the screen is changed. The default action is to ignore it.
If a program does full-screen display, it should handle @code{SIGWINCH}.
When the signal arrives, it should fetch the new screen size and
reformat its display accordingly.
+
+This macro was originally a BSD extension, but was added in
+POSIX.1-2024.
@end deftypevr
@deftypevr Macro int SIGINFO
@end deftypefun
@deftypefun {char *} secure_getenv (const char *@var{name})
-@standards{GNU, stdlib.h}
+@standards{POSIX.1-2024, stdlib.h}
@safety{@prelim{}@mtsafe{@mtsenv{}}@assafe{}@acsafe{}}
@c Calls getenv unless secure mode is enabled.
This function is similar to @code{getenv}, but it returns a null
should always prefer this function over @code{getenv} to avoid
vulnerabilities if the library is referenced from a SUID/SGID program.
-This function is a GNU extension.
+This function was originally a GNU extension, but was added in
+POSIX.1-2024.
@end deftypefun
@end deftypefun
@deftypefun size_t strlcpy (char *restrict @var{to}, const char *restrict @var{from}, size_t @var{size})
-@standards{BSD, string.h}
+@standards{POSIX-1.2024, string.h}
@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
This function copies the string @var{from} to the destination array
@var{to}, limiting the result's size (including the null terminator)
as its time cost is proportional to the length of @var{from}
even when @var{size} is small.
-This function is derived from OpenBSD 2.4.
+This function was originally derived from OpenBSD 2.4, but was added in
+POSIX.1-2024.
@end deftypefun
@deftypefun size_t wcslcpy (wchar_t *restrict @var{to}, const wchar_t *restrict @var{from}, size_t @var{size})
-@standards{BSD, string.h}
+@standards{POSIX.1-2024, string.h}
@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
This function is a variant of @code{strlcpy} for wide strings.
The @var{size} argument counts the length of the destination buffer in
wide characters (and not bytes).
-This function is derived from BSD.
+This function was originally a BSD extension, but was added in
+POSIX.1-2024.
@end deftypefun
@deftypefun size_t strlcat (char *restrict @var{to}, const char *restrict @var{from}, size_t @var{size})
-@standards{BSD, string.h}
+@standards{POSIX-1.2024, string.h}
@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
This function appends the string @var{from} to the
string @var{to}, limiting the result's total size (including the null
processing strings. Also, this function has significant performance
issues. @xref{Concatenating Strings}.
-This function is derived from OpenBSD 2.4.
+This function was originally derived from OpenBSD 2.4, but was added in
+POSIX.1-2024.
@end deftypefun
@deftypefun size_t wcslcat (wchar_t *restrict @var{to}, const wchar_t *restrict @var{from}, size_t @var{size})
-@standards{BSD, string.h}
+@standards{POSIX.1-2024, string.h}
@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
This function is a variant of @code{strlcat} for wide strings.
The @var{size} argument counts the length of the destination buffer in
wide characters (and not bytes).
-This function is derived from BSD.
+This function was originally a BSD extension, but was added in
+POSIX.1-2024.
@end deftypefun
Because these functions can abruptly truncate strings or wide strings,
@deftypefun {void *} memmem (const void *@var{haystack}, size_t @var{haystack-len},@*const void *@var{needle}, size_t @var{needle-len})
-@standards{GNU, string.h}
+@standards{POSIX.1-2024, string.h}
@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
This is like @code{strstr}, but @var{needle} and @var{haystack} are byte
arrays rather than strings. @var{needle-len} is the
length of @var{needle} and @var{haystack-len} is the length of
@var{haystack}.
-This function is a GNU extension.
+This function was originally a GNU extension, but was added in
+POSIX.1-2024.
@end deftypefun
@deftypefun size_t strspn (const char *@var{string}, const char *@var{skipset})
@end deftypefun
@deftypefun int ptsname_r (int @var{filedes}, char *@var{buf}, size_t @var{len})
-@standards{GNU, stdlib.h}
+@standards{POSIX.1-2024, stdlib.h}
@safety{@prelim{}@mtsafe{}@asunsafe{@ascuheap{/bsd}}@acunsafe{@acsmem{} @acsfd{}}}
@c ptsname_r @ascuheap/bsd @acsmem @acsfd
@c /hurd
except that it places its result into the user-specified buffer starting
at @var{buf} with length @var{len}.
-This function is a GNU extension.
+This function was originally a GNU extension, but was added in
+POSIX.1-2024.
@end deftypefun
Typical usage of these functions is illustrated by the following example:
@menu
* Thread-specific Data:: Support for creating and
managing thread-specific data
+* Waiting with Explicit Clocks:: Functions for waiting with an
+ explicit clock specification.
* POSIX Semaphores:: Support for process and thread
synchronization using semaphores
* Non-POSIX Extensions:: Additional functions to extend
@end deftypefun
+@node Waiting with Explicit Clocks
+@subsection Functions for Waiting According to a Specific Clock
+
+@Theglibc{} provides several waiting functions that expect an explicit
+@code{clockid_t} argument. These functions were all adopted by
+POSIX.1-2024.
+
+@comment pthread.h
+@deftypefun int pthread_cond_clockwait (pthread_cond_t *@var{cond}, pthread_mutex_t *@var{mutex}, clockid_t @var{clockid}, const struct timespec *@var{abstime})
+@standards{POSIX-1.2024, pthread.h}
+@safety{@prelim{}@mtsafe{}@asunsafe{@asulock{}}@acunsafe{@aculock{}}}
+@c If exactly the same function with arguments is called from a signal
+@c handler that interrupts between the mutex unlock and sleep then it
+@c will unlock the mutex twice resulting in undefined behaviour. Keep
+@c in mind that the unlock and sleep are only atomic with respect to other
+@c threads (really a happens-after relationship for pthread_cond_broadcast
+@c and pthread_cond_signal).
+@c In the AC case we would cancel the thread and the mutex would remain
+@c locked and we can't recover from that.
+Behaves like @code{pthread_cond_timedwait} except the time @var{abstime} is
+measured against the clock specified by @var{clockid} rather than the clock
+specified or defaulted when @code{pthread_cond_init} was called. Currently,
+@var{clockid} must be either @code{CLOCK_MONOTONIC} or
+@code{CLOCK_REALTIME}.
+@end deftypefun
+
+@comment pthread.h
+@deftypefun int pthread_rwlock_clockrdlock (pthread_rwlock_t *@var{rwlock}, clockid_t @var{clockid}, const struct timespec *@var{abstime})
+@standards{POSIX-1.2024, pthread.h}
+@safety{@prelim{}@mtsafe{}@asunsafe{@asulock{}}@acunsafe{@aculock{}}}
+Behaves like @code{pthread_rwlock_timedrdlock} except the time
+@var{abstime} is measured against the clock specified by @var{clockid}
+rather than @code{CLOCK_REALTIME}. Currently, @var{clockid} must be either
+@code{CLOCK_MONOTONIC} or @code{CLOCK_REALTIME}, otherwise @code{EINVAL} is
+returned.
+@end deftypefun
+
+@comment pthread.h
+@deftypefun int pthread_rwlock_clockwrlock (pthread_rwlock_t *@var{rwlock}, clockid_t @var{clockid}, const struct timespec *@var{abstime})
+@standards{POSIX-1.2024, pthread.h}
+@safety{@prelim{}@mtsafe{}@asunsafe{@asulock{}}@acunsafe{@aculock{}}}
+Behaves like @code{pthread_rwlock_timedwrlock} except the time
+@var{abstime} is measured against the clock specified by @var{clockid}
+rather than @code{CLOCK_REALTIME}. Currently, @var{clockid} must be either
+@code{CLOCK_MONOTONIC} or @code{CLOCK_REALTIME}, otherwise @code{EINVAL} is
+returned.
+@end deftypefun
+
+
@node POSIX Semaphores
@subsection POSIX Semaphores
* Default Thread Attributes:: Setting default attributes for
threads in a process.
* Initial Thread Signal Mask:: Setting the initial mask of threads.
-* Waiting with Explicit Clocks:: Functions for waiting with an
- explicit clock specification.
+* Joining Threads:: Wait for a thread to terminate.
* Single-Threaded:: Detecting single-threaded execution.
* Restartable Sequences:: Linux-specific restartable sequences
integration.
If the signal mask was copied to a heap allocation, the copy should be
freed.
-@node Waiting with Explicit Clocks
-@subsubsection Functions for Waiting According to a Specific Clock
-
-@Theglibc{} provides several waiting functions that expect an explicit
-@code{clockid_t} argument.
+@node Joining Threads
+@subsubsection Wait for a thread to terminate
-@comment pthread.h
-@comment POSIX-proposed
-@deftypefun int pthread_cond_clockwait (pthread_cond_t *@var{cond}, pthread_mutex_t *@var{mutex}, clockid_t @var{clockid}, const struct timespec *@var{abstime})
-@safety{@prelim{}@mtsafe{}@asunsafe{@asulock{}}@acunsafe{@aculock{}}}
-@c If exactly the same function with arguments is called from a signal
-@c handler that interrupts between the mutex unlock and sleep then it
-@c will unlock the mutex twice resulting in undefined behaviour. Keep
-@c in mind that the unlock and sleep are only atomic with respect to other
-@c threads (really a happens-after relationship for pthread_cond_broadcast
-@c and pthread_cond_signal).
-@c In the AC case we would cancel the thread and the mutex would remain
-@c locked and we can't recover from that.
-Behaves like @code{pthread_cond_timedwait} except the time @var{abstime} is
-measured against the clock specified by @var{clockid} rather than the clock
-specified or defaulted when @code{pthread_cond_init} was called. Currently,
-@var{clockid} must be either @code{CLOCK_MONOTONIC} or
-@code{CLOCK_REALTIME}.
-@end deftypefun
-
-@comment pthread.h
-@comment POSIX-proposed
-@deftypefun int pthread_rwlock_clockrdlock (pthread_rwlock_t *@var{rwlock}, clockid_t @var{clockid}, const struct timespec *@var{abstime})
-@safety{@prelim{}@mtsafe{}@asunsafe{@asulock{}}@acunsafe{@aculock{}}}
-Behaves like @code{pthread_rwlock_timedrdlock} except the time
-@var{abstime} is measured against the clock specified by @var{clockid}
-rather than @code{CLOCK_REALTIME}. Currently, @var{clockid} must be either
-@code{CLOCK_MONOTONIC} or @code{CLOCK_REALTIME}, otherwise @code{EINVAL} is
-returned.
-@end deftypefun
-
-@comment pthread.h
-@comment POSIX-proposed
-@deftypefun int pthread_rwlock_clockwrlock (pthread_rwlock_t *@var{rwlock}, clockid_t @var{clockid}, const struct timespec *@var{abstime})
-@safety{@prelim{}@mtsafe{}@asunsafe{@asulock{}}@acunsafe{@aculock{}}}
-Behaves like @code{pthread_rwlock_timedwrlock} except the time
-@var{abstime} is measured against the clock specified by @var{clockid}
-rather than @code{CLOCK_REALTIME}. Currently, @var{clockid} must be either
-@code{CLOCK_MONOTONIC} or @code{CLOCK_REALTIME}, otherwise @code{EINVAL} is
-returned.
-@end deftypefun
+@Theglibc{} provides several extensions to the @code{pthread_join}
+function.
@comment pthread.h
@comment GNU extension