Hi Paul, On 3/7/23 23:24, Floyd, Paul wrote: > Hi > > Quick bit of background. I'm a Valgrind maintainer and recently I've > been working on getting Valgrind to work more like the underlying OS / > libc implementations of memalign, posix_memalign and aligned_alloc. > > There are several issues with the manpage for memalign and aligned alloc. > > quote: > >        The  obsolete  function  memalign()  allocates size bytes and > returns a >        pointer to the allocated memory.  The memory address will be a > multiple >        of alignment, which must be a power of two. > > endquote: > > The power if two requirement is false for glibc which silently bumps up > the alignment to the next power of two. > > quote: > >        The  function aligned_alloc() is the same as memalign(), except > for the >        added restriction that size should be a multiple of alignment. > > endquote: > > This is also false for glibc. In the glibc implementation weak aliases > are used so memalign and aligned_alloc call the same function. > > quote: > > ERRORS >        EINVAL The alignment argument was not a power of two, or was not > a mul- >               tiple of sizeof(void *). > > endquote: > > Both of the above only apply to posix_memalign and not to either > memalign or aligned_alloc. > > There is a missing EINVAL description. If the alignment is so large that > the allocation will not be possible to satisfy then the call will fail > and set errno to EINVAL. I've CCd glibc, in case someone there can confirm in which direction they would like the manual page to go. For now, I'll add a [[deprecated]] attribute in the Synopsis for the obsolete functions. Cheers, Alex > > > Regards > > Paul > > -- GPG key fingerprint: A9348594CE31283A826FBDD8D57633D441E25BB5