bug-gnulib
[Top][All Lists]
Advanced

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

Re: new module 'aligned-malloc'


From: Paul Eggert
Subject: Re: new module 'aligned-malloc'
Date: Wed, 22 Jul 2020 14:56:45 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0

On 7/22/20 12:13 AM, Florian Weimer wrote:
I don't think it will work.  Try to get an allocation of 4096 bytes with
4096 bytes alignment using glibc malloc this way.

That's just a mental exercise since glibc malloc already has aligned_alloc, but I took the challenge anyway and found that it's eminently doable with glibc malloc alone. Run the attached program, and it should exit with status 0. At least, it works for me.

There is of course some runtime overhead, but the performance should be good enough for many, perhaps even most, Gnulib purposes; and I expect we can tweak it to run faster on Microsoft platforms (which seem to be the only major platform that still don't support aligned allocation natively) if this is a significant concern.

Attachment: malloc.c
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]