glibc/stdlib
Jonathan Wakely 8a9a593115 Add alloc_align attribute to memalign et al
GCC 4.9.0 added the alloc_align attribute to say that a function
argument specifies the alignment of the returned pointer. Clang supports
the attribute too. Using the attribute can allow a compiler to generate
better code if it knows the returned pointer has a minimum alignment.
See https://gcc.gnu.org/PR60092 for more details.

GCC implicitly knows the semantics of aligned_alloc and posix_memalign,
but not the obsolete memalign. As a result, GCC generates worse code
when memalign is used, compared to aligned_alloc.  Clang knows about
aligned_alloc and memalign, but not posix_memalign.

This change adds a new __attribute_alloc_align__ macro to <sys/cdefs.h>
and then uses it on memalign (where it helps GCC) and aligned_alloc
(where GCC and Clang already know the semantics, but it doesn't hurt)
and xposix_memalign. It can't be used on posix_memalign because that
doesn't return a pointer (the allocated pointer is returned via a void**
parameter instead).

Unlike the alloc_size attribute, alloc_align only allows a single
argument. That means the new __attribute_alloc_align__ macro doesn't
really need to be used with double parentheses to protect a comma
between its arguments. For consistency with __attribute_alloc_size__
this patch defines it the same way, so that double parentheses are
required.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
2021-10-21 00:19:20 +01:00
..
bits Make sure that the fortified function conditionals are constant 2021-10-20 18:12:41 +05:30
sys
Depend
Makefile
Versions
a64l.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
abort.c
abs.c
add_n.c
addmul_1.c
alloca.h
at_quick_exit.c
atexit.c
atof.c
atoi.c
atol.c
atoll.c
bsearch.c
bug-fmtmsg1.c
bug-getcontext.c
bug-strtod.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
bug-strtod2.c
canonicalize.c
cmp.c
cxa_at_quick_exit.c
cxa_atexit.c
cxa_finalize.c
cxa_thread_atexit_impl.c
dbl2mpn.c
div.c
divmod_1.c
divrem.c
drand48-iter.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
drand48.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
drand48_r.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
erand48.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
erand48_r.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
errno.h
exit.c
exit.h
fmtmsg.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
fmtmsg.h
fpioconst.c
fpioconst.h
gen-fpioconst.c
gen-tst-strtod-round.c
getcontext.c
getentropy.c
getenv.c
getrandom.c
getsubopt.c
gmp-impl.h
gmp.h
grouping.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
grouping.h Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
groupingwc.c
inlines.c
inttypes.h
isomac.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
jrand48.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
jrand48_r.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
l64a.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
labs.c
lcong48.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
lcong48_r.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
ldbl2mpn.c
ldiv.c
llabs.c
lldiv.c
longlong.h
lrand48.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
lrand48_r.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
lshift.c
makecontext.c
mblen.c
mbstowcs.c
mbtowc.c
mod_1.c
monetary.h
mp_clz_tab.c
mpn2dbl.c
mpn2flt.c
mpn2ldbl.c
mrand48.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
mrand48_r.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
msort.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
mul.c
mul_1.c
mul_n.c
nrand48.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
nrand48_r.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
old_atexit.c
on_exit.c
putenv.c
qsort.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
quick_exit.c
rand.c
rand_r.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
random.c
random_r.c
rpmatch.c
rshift.c
secure-getenv.c
seed48.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
seed48_r.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
setcontext.c
setenv.c
srand48.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
srand48_r.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
stdint.h
stdlib.h Add alloc_align attribute to memalign et al 2021-10-21 00:19:20 +01:00
strfmon.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
strfmon_l.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
strfrom-skeleton.c
strfromd.c
strfromf.c
strfroml.c
strtod.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
strtod_l.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
strtod_nan.c
strtod_nan_main.c
strtod_nan_narrow.h
strtod_nan_wide.h
strtof.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
strtof_l.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
strtof_nan.c
strtol.c
strtol_l.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
strtold.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
strtold_l.c
strtold_nan.c
strtoll.c
strtoll_l.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
strtoul.c
strtoul_l.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
strtoull.c
strtoull_l.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
sub_n.c
submul_1.c
swapcontext.c
system.c
tens_in_limb.c
test-a64l.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
test-at_quick_exit-race.c
test-atexit-race-common.c
test-atexit-race.c
test-bz22786.c
test-canon.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
test-canon2.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
test-cxa_atexit-race.c
test-cxa_atexit-race2.c
test-dlclose-exit-race-helper.c
test-dlclose-exit-race.c
test-on_exit-race.c
testdiv.c
testdiv.input
testmb.c
testmb2.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
testrand.c
testsort.c
tst-at_quick_exit.c
tst-atexit-common.c
tst-atexit.c
tst-atof1.c
tst-atof2.c
tst-bsearch.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
tst-bz20544.c
tst-canon-bz26341.c stdlib: Fix tst-canon-bz26341 when the glibc build current working directory is itself using symlinks. 2021-10-20 12:01:40 -03:00
tst-cxa_atexit.c
tst-empty-env.c
tst-environ.c
tst-fmtmsg.c
tst-fmtmsg.sh
tst-getrandom.c
tst-limits.c
tst-makecontext-align.c
tst-makecontext.c
tst-makecontext2.c
tst-makecontext3.c
tst-on_exit.c
tst-putenv.c
tst-putenvmod.c
tst-qsort.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
tst-qsort2.c
tst-quick_exit.cc
tst-rand48-2.c
tst-rand48.c
tst-random.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
tst-random2.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
tst-realpath.c
tst-secure-getenv.c
tst-setcontext.c Fix stdlib/tst-setcontext.c for GCC 12 -Warray-compare 2021-10-05 14:25:40 +00:00
tst-setcontext2.c
tst-setcontext3.c
tst-setcontext3.sh
tst-setcontext4.c
tst-setcontext5.c
tst-setcontext6.c
tst-setcontext7.c
tst-setcontext8.c
tst-setcontext9.c
tst-strfmon_l.c
tst-strfrom-locale.c
tst-strfrom.c
tst-strfrom.h
tst-strtod-nan-locale-main.c
tst-strtod-nan-locale.c
tst-strtod-nan-sign-main.c
tst-strtod-nan-sign.c
tst-strtod-overflow.c
tst-strtod-round-data
tst-strtod-round-data.h
tst-strtod-round-skeleton.c
tst-strtod-round.c
tst-strtod-underflow.c
tst-strtod.c
tst-strtod.h
tst-strtod1i.c
tst-strtod2.c
tst-strtod3.c
tst-strtod4.c
tst-strtod5.c
tst-strtod5i.c
tst-strtod6.c
tst-strtol-locale-main.c
tst-strtol-locale.c
tst-strtol.c
tst-strtoll.c
tst-swapcontext1.c
tst-system.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
tst-thread-quick_exit.cc
tst-tininess.c
tst-tls-atexit-lib.c
tst-tls-atexit-nodelete.c
tst-tls-atexit.c
tst-unsetenv1.c
tst-width-stdint.c
tst-width.c
tst-xpg-basename.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
ucontext.h
udiv_qrnnd.c
wcstombs.c
wctomb.c
xpg_basename.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30