|
From: | Paul Eggert |
Subject: | Re: new module 'aligned-malloc' |
Date: | Tue, 21 Jul 2020 08:42:56 -0700 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 |
On 7/21/20 1:47 AM, Bruno Haible wrote:
The posix_memalign and memalign functions only help on those platforms where they exist. It's not possible to emulate posix_memalign or memalign when they are not present, because when malloc() returned p, we can call free (p) but not free (p+4) or free (p+8) or similar. Gnulib has a module 'pagealign_alloc' but it produces a getpagesize() alignment - not useful (very wasteful) for a 16-bytes alignment.
C11 and C++17 have aligned_alloc, which Emacs uses in preference to posix_memalign. Is there some reason this new module doesn't use aligned_alloc? If so, that should be documented; if not, I suggest preferring aligned_alloc to posix_memalign since aligned_alloc should be available on more systems as the new standards take hold.
Also, how about naming the new module 'aligned-alloc' and having it implement aligned_alloc? That would make for more-seamless integration.
[Prev in Thread] | Current Thread | [Next in Thread] |