posix_memalign.3: drop obsolete requirement for aligned_alloc() usage
PATCH 1/1 posix_memalign.3: drop obsolete requirement for aligned_alloc() usage
A C11 defect report changed the description of aligned_alloc() so that it is no longer necessary for the allocation size to be a multiple of the alignment. Although this isn't yet reflected in the GNU C Library manual, I'm preparing a patch for them as well.
Here is the DR:
http://www.open-std.org/jtc1/sc22/wg14/www/docs/summary.htm#dr_460
From 89560bc9ad887504cf557db3579441d2d838aff6 Mon Sep 17 00:00:00 2001
From: John Scott <[email protected]>
Date: Thu, 21 Oct 2021 04:53:39 -0400
Subject: [PATCH] posix_memalign.3: drop obsolete requirement for
aligned_alloc() usage
In the C11 standard as published, it was undefined behavior if the allocation size was not a multiple of the system page size. Defect Report 460 changed the relevant sentence from "The value of alignment shall be a valid alignment supported by the implementation and the value of size shall be an integral multiple of alignment." to
"If the value of alignment is not a valid alignment supported by the implementation the function shall fail by returning a null pointer," and hence dropped the requirement.
This is supported in practice; in the GNU C Library, aligned_alloc() is implemented as an alias for memalign(). The GNU C Library manual still documents the obsolete requirement however.
--- man3/posix_memalign.3 | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
man3/posix_memalign.3 +1 -5
@@ -104,11 +104,7 @@ which must be a power of two. The function .BR aligned_alloc () is the same as -.BR memalign (), -except for the added restriction that -.I size -should be a multiple of -.IR alignment . +.BR memalign () . .PP The obsolete function .BR valloc ()
Signature · 1 line
2.33.0