Reduce code duplication in machine/_types.h
authorAlex Richardson <arichardson@FreeBSD.org>
Mon, 14 Jun 2021 10:18:51 +0000 (10:18 +0000)
committerAlex Richardson <arichardson@FreeBSD.org>
Mon, 14 Jun 2021 15:30:16 +0000 (16:30 +0100)
commit9bb8a4091c4f63dacda5108f4f994f7f6b35bbf1
tree7632c5604834046370ad68067058588d2ea7fec8
parent15fa52a56494d050c4b8e1535d98e2fd416f1944
Reduce code duplication in machine/_types.h

Many of these typedefs are the same across all architectures or can
be set based on an architecture-independent compiler-provided macro
(e.g. __SIZEOF_SIZE_T__). These macros have been available since GCC 4.6
and Clang sometime before 3.0 (godbolt.org does not have any older clang
versions installed).

I originally considered using the compiler-provided `__FOO_TYPE__` directly.
However, in order to do so we have to check that those match the previous
typedef exactly (not just that they have the same size) since any change
would be an ABI break. For example, changing `long` to `long long` results
in different C++ name mangling. Additionally, Clang and GCC disagree on
the underlying type for some of (u)int*_fast_t types, so this change
only moves the definitions that are identical across all architectures
and does not touch those types.

This de-deduplication will allow us to have a smaller diff downstream in
CheriBSD: we only have to only change the (u)intptr_t definition in
sys/_types.h in CheriBSD instead of having to change machine/_types.h for
all CHERI-enabled architectures (currently RISC-V, AArch64 and MIPS).

Reviewed By: imp, kib
Differential Revision: https://reviews.freebsd.org/D29895
include/pthread.h
sys/arm/include/_types.h
sys/arm64/include/_types.h
sys/mips/include/_types.h
sys/powerpc/include/_types.h
sys/riscv/include/_types.h
sys/sys/_types.h
sys/sys/stddef.h
sys/x86/include/_types.h
sys/x86/include/reg.h