mirror of
https://git.savannah.gnu.org/git/gnulib.git
synced 2025-09-11 11:50:52 +03:00
* lib/posix_memalign.c: Include stdckdint.h. (posix_memalign): Test for overflow more straightforwardly, and more portably to unlikely platforms where SIZE_MAX <= INT_MAX. Treat a zero size as if it were alignment. * m4/posix_memalign.m4 (gl_FUNC_POSIX_MEMALIGN): * tests/test-posix_memalign.c (main): Test zero size too. Use volatile to avoid compiler optimizations. * modules/posix_memalign (Depends-on): Add stdckdint.
42 lines
1.3 KiB
Plaintext
42 lines
1.3 KiB
Plaintext
@node posix_memalign
|
|
@subsection @code{posix_memalign}
|
|
@findex posix_memalign
|
|
|
|
POSIX specification:@* @url{https://pubs.opengroup.org/onlinepubs/9799919799/functions/posix_memalign.html}
|
|
|
|
Gnulib module: posix_memalign
|
|
@mindex posix_memalign
|
|
|
|
Although this function is superseded by @code{aligned_alloc},
|
|
it is more portable to older systems that do not support C11.
|
|
@xref{aligned_alloc}.
|
|
|
|
Portability problems fixed by Gnulib:
|
|
@itemize
|
|
@item
|
|
This function returns a null pointer if the size argument is zero:
|
|
AIX 7.3.
|
|
@item
|
|
This function produces misaligned results on some platforms:
|
|
OpenBSD 6.1.
|
|
@end itemize
|
|
|
|
Portability problems not fixed by Gnulib:
|
|
@itemize
|
|
@item
|
|
This function is missing on some platforms:
|
|
Mac OS X 10.5, FreeBSD 6.0, NetBSD 3.0, OpenBSD 3.8, Minix 3.1.8, AIX 5.1, HP-UX 11, Solaris 10, Cygwin 1.5.x, mingw, MSVC 14, Android 4.1.
|
|
@item
|
|
If the alignment and size are absurdly large, this function crashes:
|
|
@c https://sourceware.org/bugzilla/show_bug.cgi?id=32301
|
|
glibc 2.40.
|
|
@end itemize
|
|
|
|
@mindex aligned-malloc
|
|
The Gnulib module @code{aligned-malloc} provides functions for
|
|
allocating and freeing blocks of suitably aligned memory.
|
|
|
|
@mindex pagealign_alloc
|
|
The Gnulib module @code{pagealign_alloc} provides a similar API for
|
|
allocating and freeing blocks of memory aligned on a system page boundary.
|