diff options
author | Alex Richardson <arichardson@FreeBSD.org> | 2021-06-14 10:18:51 +0000 |
---|---|---|
committer | Alex Richardson <arichardson@FreeBSD.org> | 2021-06-14 15:30:16 +0000 |
commit | 9bb8a4091c4f63dacda5108f4f994f7f6b35bbf1 (patch) | |
tree | 7632c5604834046370ad68067058588d2ea7fec8 /sys/arm | |
parent | 15fa52a56494d050c4b8e1535d98e2fd416f1944 (diff) | |
download | src-9bb8a4091c4f63dacda5108f4f994f7f6b35bbf1.tar.gz src-9bb8a4091c4f63dacda5108f4f994f7f6b35bbf1.zip |
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
Diffstat (limited to 'sys/arm')
-rw-r--r-- | sys/arm/include/_types.h | 43 |
1 files changed, 2 insertions, 41 deletions
diff --git a/sys/arm/include/_types.h b/sys/arm/include/_types.h index 14ab76c5fbde..fb52df9dfcd6 100644 --- a/sys/arm/include/_types.h +++ b/sys/arm/include/_types.h @@ -41,31 +41,11 @@ #ifndef _MACHINE__TYPES_H_ #define _MACHINE__TYPES_H_ -#ifndef _SYS_CDEFS_H_ -#error this file needs sys/cdefs.h as a prerequisite +#ifndef _SYS__TYPES_H_ +#error do not include this header, use sys/_types.h #endif /* - * Basic types upon which most other types are built. - */ -typedef signed char __int8_t; -typedef unsigned char __uint8_t; -typedef short __int16_t; -typedef unsigned short __uint16_t; -typedef int __int32_t; -typedef unsigned int __uint32_t; -#ifndef lint -__extension__ -#endif -/* LONGLONG */ -typedef long long __int64_t; -#ifndef lint -__extension__ -#endif -/* LONGLONG */ -typedef unsigned long long __uint64_t; - -/* * Standard type definitions. */ typedef __uint32_t __clock_t; /* clock()... */ @@ -74,38 +54,19 @@ typedef __int32_t __critical_t; typedef double __double_t; typedef float __float_t; #endif -typedef __int32_t __intfptr_t; -typedef __int64_t __intmax_t; -typedef __int32_t __intptr_t; typedef __int32_t __int_fast8_t; typedef __int32_t __int_fast16_t; typedef __int32_t __int_fast32_t; typedef __int64_t __int_fast64_t; -typedef __int8_t __int_least8_t; -typedef __int16_t __int_least16_t; -typedef __int32_t __int_least32_t; -typedef __int64_t __int_least64_t; -typedef __int32_t __ptrdiff_t; /* ptr1 - ptr2 */ typedef __int32_t __register_t; typedef __int32_t __segsz_t; /* segment size (in pages) */ -typedef __uint32_t __size_t; /* sizeof() */ -typedef __int32_t __ssize_t; /* byte count or error */ typedef __int64_t __time_t; /* time()... */ -typedef __uint32_t __uintfptr_t; -typedef __uint64_t __uintmax_t; -typedef __uint32_t __uintptr_t; typedef __uint32_t __uint_fast8_t; typedef __uint32_t __uint_fast16_t; typedef __uint32_t __uint_fast32_t; typedef __uint64_t __uint_fast64_t; -typedef __uint8_t __uint_least8_t; -typedef __uint16_t __uint_least16_t; -typedef __uint32_t __uint_least32_t; -typedef __uint64_t __uint_least64_t; typedef __uint32_t __u_register_t; -typedef __uint32_t __vm_offset_t; typedef __uint32_t __vm_paddr_t; -typedef __uint32_t __vm_size_t; typedef unsigned int ___wchar_t; #define __WCHAR_MIN 0 /* min value for a wchar_t */ |