[PATCH] posix_memalign.3: drop obsolete requirement for aligned_alloc() usage

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <jscott@xxxxxxxxxx>
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(-)

diff --git a/man3/posix_memalign.3 b/man3/posix_memalign.3
index 931ec1c07..934fd22d1 100644
--- a/man3/posix_memalign.3
+++ b/man3/posix_memalign.3
@@ -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 ()
-- 
2.33.0

Attachment: signature.asc
Description: This is a digitally signed message part


[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux