[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: new module 'aligned-malloc'
From: |
Jeffrey Walton |
Subject: |
Re: new module 'aligned-malloc' |
Date: |
Tue, 21 Jul 2020 17:43:17 -0400 |
On Tue, Jul 21, 2020 at 5:18 PM Paul Eggert <eggert@cs.ucla.edu> wrote:
>
> On 7/21/20 8:51 AM, Florian Weimer wrote:
> > The official aligned_alloc produces pointers compatible with free.
> > This module cannot do that.
>
> I don't see why not, at least on platforms of interest to Gnulib. On systems
> that provide no native way to do an aligned allocation, we merely keep calling
> malloc with suitable arguments until we get a pointer that is suitably
> aligned.
> We then free all the unsuitable storage we allocated along the way, and return
> the good pointer.
>
> Of course this would not be as efficient as a native aligned_alloc would be,
> but
> it should be good enough for portability to nonstandard platforms, for many
> applications anyway - and that is the Gnulib Way.
>
> Eventually I hope even Microsoft will figure out how to do aligned allocation,
> and even if my hope is dashed that's OK, our code will still work.
I believe Redmond has _aligned_malloc.
> There is a real advantage to using aligned_alloc instead of some nonstandard
> allocate/free pair. With aligned_alloc you can hand pointers off to other code
> that expects to use 'free' (and there is a lot of such code out there).
Plus, I believe the compiler can track pointer alignment better.
I've never been able to get GCC's __builtin_assume_aligned to work. My
attempts to use it always seem to crash.
Jeff
Jeff
- new module 'aligned-malloc', Bruno Haible, 2020/07/21
- Re: new module 'aligned-malloc', Paul Eggert, 2020/07/21
- Re: new module 'aligned-malloc', Florian Weimer, 2020/07/21
- Re: new module 'aligned-malloc', Bruno Haible, 2020/07/21
- Re: new module 'aligned-malloc', Paul Eggert, 2020/07/22
- Re: new module 'aligned-malloc', Bruno Haible, 2020/07/22
- Re: new module 'aligned-malloc', Jeffrey Walton, 2020/07/22
- Re: new module 'aligned-malloc', Paul Eggert, 2020/07/22
- Re: Minix, Bruno Haible, 2020/07/23
- Re: new module 'aligned-malloc', Florian Weimer, 2020/07/22
- Re: new module 'aligned-malloc', Paul Eggert, 2020/07/22
- Re: new module 'aligned-malloc', Florian Weimer, 2020/07/23