On Wed, 10 Sep 2025, Collin Funk wrote:
Harry Sintonen <[email protected]> writes:
pagealign code (lib/pagealign_alloc.c) has a mistake whereas USE_MMAP
code uses the linked list to maintain the memory allocations. This is
unnessary as mmap() always returns memory aligned to the page size.
Thus the buffer could be passed as-is, similar to what
HAVE_POSIX_MEMALIGN code is doing.
It is true that Linux returns a page-aligned address, but it isn't
required by POSIX [1].
Oh, right, missed that (should not read just linux man pages heh). One
way to get optimal performance on most platforms (that do return aligned
pointer) would be to check if the pointer is already aligned. If it is
aligned already, do not store entry to the list and just return the
pointer.
Then at pagealign_free: if the entry is not found in the list perform
direct munmap(). With systems that align the mmap() return values the list
will always be empty, leading to O(1) complexity.
Regards,
--
l=2001;main(i){float o,O,_,I,D;for(;O=I=l/571.-1.75,l;)for(putchar(--l%80?
i:10),o=D=l%80*.05-2,i=31;_=O*O,O=2*o*O+I,o=o*o-_+D,o+_+_<4+D&i++<87;);puts
(" Harry 'Piru' Sintonen <[email protected]> https://www.iki.fi/sintonen");}