public inbox for linux-man@vger.kernel.org
 help / color / mirror / Atom feed
* Issues in manpage memalign
@ 2023-03-07 22:24 Floyd, Paul
  2023-03-10  0:35 ` Alejandro Colomar
  0 siblings, 1 reply; 6+ messages in thread
From: Floyd, Paul @ 2023-03-07 22:24 UTC (permalink / raw)
  To: linux-man; +Cc: mtk.manpages, alx.manpages

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.


Regards

Paul



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-03-10  7:23 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-07 22:24 Issues in manpage memalign Floyd, Paul
2023-03-10  0:35 ` Alejandro Colomar
2023-03-10  3:02   ` DJ Delorie
2023-03-10  7:21     ` Paul Floyd
2023-03-10  4:05   ` Xi Ruoyao
2023-03-10  7:15     ` Paul Floyd

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox