acadia-newlib/newlib/libc/include/sys
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
..
_default_fcntl.h change _COMPILING_NEWLIB to _LIBC 2021-11-15 19:32:23 -05:00
_intsup.h Support calculation of pointer size for __int20__ type in _intsup.h 2019-06-25 13:37:16 -04:00
_locale.h Rename <xlocale.h> back to <sys/_locale.h> 2019-06-14 10:02:08 +02:00
_pthreadtypes.h Fix guard for siginfo_t and pthread_t definition 2017-06-19 13:00:05 +02:00
_sigset.h FreeBSD compatibility for <sys/select.h> 2015-12-14 15:39:44 +01:00
_stdint.h Provide __intmax_t and __uintmax_t 2016-10-25 16:24:05 +02:00
_timespec.h Synchronize <sys/_timespec.h> with FreeBSD 2019-11-04 07:03:15 +01:00
_timeval.h Move timeval macros to <sys/time.h> 2019-11-04 07:03:15 +01:00
_types.h Reduce namespace pollution from <sys/_types.h> 2022-07-08 06:57:52 +02:00
_tz_structs.h libc/time: Move internal newlib tz-structs into own header 2020-10-15 16:59:51 +02:00
cdefs.h Expose clang's alignment builtins and use them for roundup2/rounddown2 2022-07-11 11:52:46 +02:00
config.h Use global stdio streams for all configurations 2022-06-10 20:13:52 +02:00
custom_file.h
dir.h * libc/include/sys/dir.h: New BSD-compatibility header. 2010-08-11 18:14:54 +00:00
dirent.h
errno.h ansification: remove _PARAMS 2018-01-17 11:47:13 -06:00
fcntl.h
features.h change _COMPILING_NEWLIB to _LIBC 2021-11-15 19:32:23 -05:00
fenv.h Add default implementation of fenv.h and all methods 2019-08-09 17:49:16 +02:00
file.h
iconvnls.h ansification: remove _EXFUN, _EXFUN_NOTHROW 2018-01-17 11:47:29 -06:00
lock.h ansification: remove _CAST_VOID 2018-01-17 11:47:17 -06:00
param.h Move fd_stuff from sys/types.h to sys/select.h 2015-12-07 16:28:22 +01:00
queue.h This commit brings in a new refactored TCP stack called Rack. 2018-08-24 15:00:04 +02:00
reent.h Use global stdio streams for all configurations 2022-06-10 20:13:52 +02:00
resource.h ansification: remove _EXFUN, _EXFUN_NOTHROW 2018-01-17 11:47:29 -06:00
sched.h Add and use latest <sys/timespec.h> from FreeBSD 2015-03-11 15:45:38 +01:00
select.h Cygwin: redefine some macros for Linux compatibility 2022-07-07 08:22:40 -04:00
signal.h change _COMPILING_NEWLIB to _LIBC 2021-11-15 19:32:23 -05:00
stat.h Cygwin: simplify some function names 2022-05-29 17:45:52 -04:00
stdio.h ansification: remove _CAST_VOID 2018-01-17 11:47:17 -06:00
string.h
syslimits.h Use remove-advertising-clause script to edit BSD licenses 2020-01-29 19:03:31 +01:00
time.h Revert "sys/types.h: Don't include sys/_stdint.h" 2022-05-04 15:08:44 +02:00
timeb.h ansification: remove _PARAMS 2018-01-17 11:47:13 -06:00
times.h change _COMPILING_NEWLIB to _LIBC 2021-11-15 19:32:23 -05:00
timespec.h Add and use latest <sys/timespec.h> from FreeBSD 2015-03-11 15:45:38 +01:00
tree.h sys/tree.h: Red child with black sibling rotations 2021-10-07 17:58:36 +02:00
types.h Reduce namespace pollution from <sys/_types.h> 2022-07-08 06:57:52 +02:00
unistd.h Cygwin: simplify some function names 2022-05-29 17:45:52 -04:00
utime.h
wait.h change _COMPILING_NEWLIB to _LIBC 2021-11-15 19:32:23 -05:00