[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: new module 'aligned-malloc'
From: |
Bruno Haible |
Subject: |
Re: new module 'aligned-malloc' |
Date: |
Tue, 21 Jul 2020 13:24:32 +0200 |
User-agent: |
KMail/5.1.3 (Linux/4.4.0-179-generic; KDE/5.18.0; x86_64; ; ) |
Hi Jeffrey,
> Checkout https://forum.kde.org/viewtopic.php?p=66274 for some info on
> detection of posix_memalign.
It's well-known that you can't use standards symbols like __STDC_VERSION__
or _XOPEN_SOURCE for hardly anything. We wouldn't have hundreds of
AC_CHECK_FUNC calls in gnulib/m4/ if they weren't needed.
> I think there's also another option, if interested. On x86 you can get
> aligned allocations with _mm_malloc.
_mm_malloc is not in the libc of any system I know of. The docs [1] state
that it is a compiler built-in. If it relies on an Intel library, that
would make it unsuitable for use in gnulib (since it would introduce an
additional link dependency for something that should not need one).
> And with PPC you can get an
> aligned block with vec_malloc.
On AIX, yes, not on Linux/PowerPC nor on Mac OS X/PowerPC. But the only
documentation of this function that I can find [2] is not a reference
documentation. Why would I use a function that has no reference documentation?
> As you probably know, Linux aligns heap allocations to 16 by default.
It's the libc which does this, not the kernel. And glibc aligns malloc()
results to 8 bytes on most 32-bit platforms.
Bruno
[1]
https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=_mm_free&expand=5236,3543
[2]
https://www.ibm.com/support/knowledgecenter/ssw_aix_72/generalprogramming/vector_prog.html