Hash :
3498a703
Author :
Date :
2024-07-31T17:10:56
errno: make EEXIST != ENOTEMPTY on AIX Also, improve errno tests. * m4/calloc.m4 (gl_FUNC_CALLOC_GNU): * m4/malloc.m4 (gl_FUNC_MALLOC_GNU): * m4/realloc.m4 (gl_FUNC_REALLOC_GNU): * m4/scandir.m4 (gl_FUNC_SCANDIR): Define _LINUX_SOURCE_COMPAT, as this can sometimes help on AIX. * m4/errno_h.m4 (gl_HEADER_ERRNO_H): Define _LINUX_SOURCE_COMPAT, to make EEXIST != ENOTEMPTY. * m4/strerror_r.m4 (gl_FUNC_STRERROR_R): Define _LINUX_SOURCE_COMPAT, in case someone else does. * modules/errno-tests (Depends-on): Add assert-h, c99. * tests/test-errno.c (e1, ..., e131): Remove, replacing with ... (CHECK_POSIX_ERRNOS, POSITIVE_INTEGER_CONSTANT_EXPRESSION) (INDEXED_BY_ERRNO, ERRNO_COUNT): These new macros. Check that all errno values are positive integer constant expressions. Check that they are all distinct, except perhaps for EWOULDBLOCK == EAGAIN and ENOTSUP == EOPNOTSUPP. Also check ESOCKTNOSUPPORT, added in POSIX.1-2024. Also, check that errno values are distinct except when POSIX says they needn’t be distinct, since POSIX.1-2024 gives license to GNU/Linux’s non-distinct values.
@node calloc
@subsection @code{calloc}
@findex calloc
POSIX specification:@* @url{https://pubs.opengroup.org/onlinepubs/9799919799/functions/calloc.html}
Gnulib module: calloc-posix
Portability problems fixed by Gnulib:
@itemize
@item
Upon failure, the function does not set @code{errno} to @code{ENOMEM} on
some platforms:
mingw, MSVC 14.
@item
On some platforms, @code{calloc (n, s)} can succeed even if
multiplying @code{n} by @code{s} would exceed @code{PTRDIFF_MAX} or
@code{SIZE_MAX}. Although failing to check for exceeding
@code{PTRDIFF_MAX} is arguably allowed by POSIX it can lead to
undefined behavior later, so @code{calloc-posix} does not allow
going over the limit.
@end itemize
Extension: Gnulib provides a module @samp{calloc-gnu} that substitutes a
@code{calloc} implementation that behaves more like the glibc implementation.
It fixes this portability problem:
@itemize
@item
@code{calloc (0, s)} and @code{calloc (n, 0)} return @code{NULL} on success
on some platforms:
AIX 7.3.
@end itemize