acadia-newlib/newlib/libc
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
..
argz newlib: libc: merge build up a directory 2022-03-16 21:18:25 -04:00
ctype newlib: libc: merge build up a directory 2022-03-16 21:18:25 -04:00
errno newlib: libc: merge build up a directory 2022-03-16 21:18:25 -04:00
iconv iconv: Fix EL/IX level 2 handling 2022-03-21 11:32:59 +01:00
include Expose clang's alignment builtins and use them for roundup2/rounddown2 2022-07-11 11:52:46 +02:00
locale newlib: libc: merge build up a directory 2022-03-16 21:18:25 -04:00
machine Remove _global_impure_ptr indirection 2022-05-04 17:31:04 +02:00
misc Remove __sinit_locks / __sinit_recursive_mutex 2022-05-13 12:31:56 +02:00
posix Cygwin: simplify some function names 2022-05-29 17:45:52 -04:00
reent Use global stdio streams for all configurations 2022-06-10 20:13:52 +02:00
search newlib: libc: merge build up a directory 2022-03-16 21:18:25 -04:00
signal newlib: libc: merge build up a directory 2022-03-16 21:18:25 -04:00
ssp newlib: libc: merge build up a directory 2022-03-16 21:18:25 -04:00
stdio Cygwin: stdio: don't try again to read after EOF 2022-07-04 18:55:08 -04:00
stdio64 newlib: libc: merge build up a directory 2022-03-16 21:18:25 -04:00
stdlib Use global atexit data for all configurations 2022-05-18 07:45:09 +02:00
string newlib: libc: merge build up a directory 2022-03-16 21:18:25 -04:00
sys Reduce namespace pollution from <sys/_types.h> 2022-07-08 06:57:52 +02:00
syscalls newlib: libc: merge build up a directory 2022-03-16 21:18:25 -04:00
time Modify tzset_r.c to handle errors 2022-05-27 11:05:11 -04:00
unix newlib: libc: merge build up a directory 2022-03-16 21:18:25 -04:00
xdr newlib: libc: merge build up a directory 2022-03-16 21:18:25 -04:00
Makefile.inc Silence xsltproc when writing manpages 2022-05-04 17:05:52 -04:00
Makefile.unidata
acinclude.m4 newlib: drop phoenix support 2022-03-28 23:17:06 -04:00
libc.in.xml Generate manpages for functions in chapter sys.tex 2022-05-04 17:06:19 -04:00
libc.texi newlib: libc: include all chapters all the time in the manual 2022-02-04 19:39:09 -05:00
sys.tex