acadia-newlib/newlib/libc/include
Alex Richardson 68109f904b Expose clang's alignment builtins and use them for roundup2/rounddown2
This makes roundup2/rounddown2 type- and const-preserving and allows
using it on pointer types without casting to uintptr_t first. Not
performing pointer-to-integer conversions also helps the compiler's
optimization passes and can therefore result in better code generation.
When using it with integer values there should be no change other than
the compiler checking that the alignment value is a valid power-of-two.

I originally implemented these builtins for CHERI a few years ago and
they have been very useful for CheriBSD. However, they are also useful
for non-CHERI code so I was able to upstream them for Clang 10.0.

Rationale from the clang documentation:
Clang provides builtins to support checking and adjusting alignment
of pointers and integers. These builtins can be used to avoid relying
on implementation-defined behavior of arithmetic on integers derived
from pointers. Additionally, these builtins retain type information
and, unlike bitwise arithmetic, they can perform semantic checking on
the alignment value.

There is also a feature request for GCC, so GCC may also support it in
the future: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98641

Reviewed By:	brooks, jhb, imp
Differential Revision: https://reviews.freebsd.org/D28332
2022-07-11 11:52:46 +02:00
..
machine Revert "sys/types.h: Don't include sys/_stdint.h" 2022-05-04 15:08:44 +02:00
rpc
ssp
sys Expose clang's alignment builtins and use them for roundup2/rounddown2 2022-07-11 11:52:46 +02:00
_ansi.h
_newlib_version.h
_syslist.h
alloca.h
ar.h Use remove-advertising-clause script to edit BSD licenses 2020-01-29 19:03:31 +01:00
argz.h
assert.h
complex.h
cpio.h
ctype.h Revert "ctype: use less short names in public header" 2021-12-03 10:50:58 +01:00
devctl.h libc/include/newlib.h: Fix C++ compilation issue 2020-11-16 08:15:18 -06:00
dirent.h change _COMPILING_NEWLIB to _LIBC 2021-11-15 19:32:23 -05:00
elf.h
envlock.h
envz.h
errno.h
fastmath.h
fcntl.h
fenv.h Add default implementation of fenv.h and all methods 2019-08-09 17:49:16 +02:00
fnmatch.h
ftw.h FTW Port for Newlib 2021-02-09 11:07:59 +01:00
getopt.h
glob.h
grp.h Use remove-advertising-clause script to edit BSD licenses 2020-01-29 19:03:31 +01:00
iconv.h
ieeefp.h
inttypes.h inttypes.h: Use reserved names for function parameters 2021-06-25 16:48:31 -04:00
langinfo.h Rename <xlocale.h> back to <sys/_locale.h> 2019-06-14 10:02:08 +02:00
libgen.h
limits.h
locale.h change _COMPILING_NEWLIB to _LIBC 2021-11-15 19:32:23 -05:00
malloc.h
math.h Aarch32/64: Support __FLT_EVAL_METHOD__ values other than 0, 1, 2 2022-04-11 12:00:16 -04:00
memory.h
ndbm.h Fix ndbm.c build break 2022-05-04 13:08:10 -04:00
newlib.h
paths.h
pthread.h libc: Added prototypes for new POSIX APIs 2021-08-09 10:29:55 +02:00
pwd.h Cygwin: simplify some function names 2022-05-29 17:45:52 -04:00
reent.h change _COMPILING_NEWLIB to _LIBC 2021-11-15 19:32:23 -05:00
regdef.h
regex.h
sched.h sched.h: Declare affinity functions only on targets supporting them 2019-08-12 17:30:20 +02:00
search.h
setjmp.h
signal.h
spawn.h
stdatomic.h sys: clean up empty lines in .c and .h files 2020-10-26 14:18:46 +01:00
stdint.h
stdio.h In <stdio.h> provide only necessary types 2022-05-04 15:08:53 +02:00
stdio_ext.h
stdlib.h Rename <xlocale.h> back to <sys/_locale.h> 2019-06-14 10:02:08 +02:00
string.h Unconditionally declare strsignal 2021-10-27 20:02:06 +02:00
strings.h Rename <xlocale.h> back to <sys/_locale.h> 2019-06-14 10:02:08 +02:00
tar.h
termios.h
tgmath.h
threads.h
time.h libc/time: Move internal newlib tz-structs into own header 2020-10-15 16:59:51 +02:00
unctrl.h Use remove-advertising-clause script to edit BSD licenses 2020-01-29 19:03:31 +01:00
unistd.h
utime.h
utmp.h
wchar.h libc/include/wchar.h: Remove parameter name 2020-10-02 17:02:28 -04:00
wctype.h Rename <xlocale.h> back to <sys/_locale.h> 2019-06-14 10:02:08 +02:00
wordexp.h