Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 14 Jun 2021 15:34:09 GMT
From:      Alex Richardson <arichardson@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 9bb8a4091c4f - main - Reduce code duplication in machine/_types.h
Message-ID:  <202106141534.15EFY96S073885@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by arichardson:

URL: https://cgit.FreeBSD.org/src/commit/?id=9bb8a4091c4f63dacda5108f4f994f7f6b35bbf1

commit 9bb8a4091c4f63dacda5108f4f994f7f6b35bbf1
Author:     Alex Richardson <arichardson@FreeBSD.org>
AuthorDate: 2021-06-14 10:18:51 +0000
Commit:     Alex Richardson <arichardson@FreeBSD.org>
CommitDate: 2021-06-14 15:30:16 +0000

    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            |  2 +-
 sys/arm/include/_types.h     | 43 ++----------------------
 sys/arm64/include/_types.h   | 35 ++------------------
 sys/mips/include/_types.h    | 60 ++--------------------------------
 sys/powerpc/include/_types.h | 60 ++--------------------------------
 sys/riscv/include/_types.h   | 35 ++------------------
 sys/sys/_types.h             | 78 ++++++++++++++++++++++++++++++++++++++++++++
 sys/sys/stddef.h             |  2 +-
 sys/x86/include/_types.h     | 51 ++---------------------------
 sys/x86/include/reg.h        |  2 +-
 10 files changed, 93 insertions(+), 275 deletions(-)

diff --git a/include/pthread.h b/include/pthread.h
index 143401ddf68b..455e27b89f8b 100644
--- a/include/pthread.h
+++ b/include/pthread.h
@@ -43,7 +43,7 @@
 #include <sys/cdefs.h>
 #include <sys/_pthreadtypes.h>
 #include <machine/_limits.h>
-#include <machine/_types.h>
+#include <sys/_types.h>
 #include <sys/_sigset.h>
 #include <sched.h>
 #include <time.h>
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,30 +41,10 @@
 #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.
  */
@@ -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 */
diff --git a/sys/arm64/include/_types.h b/sys/arm64/include/_types.h
index b54a17d25024..720900a270d4 100644
--- a/sys/arm64/include/_types.h
+++ b/sys/arm64/include/_types.h
@@ -35,22 +35,10 @@
 #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;
-typedef	long			__int64_t;
-typedef	unsigned long		__uint64_t;
-
 /*
  * Standard type definitions.
  */
@@ -60,38 +48,19 @@ typedef	__int64_t	__critical_t;
 typedef	double		__double_t;
 typedef	float		__float_t;
 #endif
-typedef	__int64_t	__intfptr_t;
-typedef	__int64_t	__intmax_t;
-typedef	__int64_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	__int64_t	__ptrdiff_t;		/* ptr1 - ptr2 */
 typedef	__int64_t	__register_t;
 typedef	__int64_t	__segsz_t;		/* segment size (in pages) */
-typedef	__uint64_t	__size_t;		/* sizeof() */
-typedef	__int64_t	__ssize_t;		/* byte count or error */
 typedef	__int64_t	__time_t;		/* time()... */
-typedef	__uint64_t	__uintfptr_t;
-typedef	__uint64_t	__uintmax_t;
-typedef	__uint64_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	__uint64_t	__u_register_t;
-typedef	__uint64_t	__vm_offset_t;
 typedef	__uint64_t	__vm_paddr_t;
-typedef	__uint64_t	__vm_size_t;
 typedef	unsigned int	___wchar_t;
 
 #define	__WCHAR_MIN	0		/* min value for a wchar_t */
diff --git a/sys/mips/include/_types.h b/sys/mips/include/_types.h
index 385280b1ea45..dd433eaec316 100644
--- a/sys/mips/include/_types.h
+++ b/sys/mips/include/_types.h
@@ -42,33 +42,8 @@
 #ifndef _MACHINE__TYPES_H_
 #define	_MACHINE__TYPES_H_
 
-#ifndef _SYS_CDEFS_H_
-#error this file needs sys/cdefs.h as a prerequisite
-#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;
-#ifdef __mips_n64
-typedef	long			__int64_t;
-typedef	unsigned long		__uint64_t;
-#else
-#ifndef lint
-__extension__
-#endif
-/* LONGLONG */
-typedef	long long		__int64_t;
-#ifndef lint
-__extension__
-#endif
-/* LONGLONG */
-typedef	unsigned long long	__uint64_t;
+#ifndef _SYS__TYPES_H_
+#error do not include this header, use sys/_types.h
 #endif
 
 /*
@@ -81,22 +56,13 @@ typedef	float		__float_t;
 #endif
 #ifdef __mips_n64
 typedef	__int64_t	__critical_t;
-typedef	__int64_t	__intfptr_t;
-typedef	__int64_t	__intptr_t;
 #else
 typedef	__int32_t	__critical_t;
-typedef	__int32_t	__intfptr_t;
-typedef	__int32_t	__intptr_t;
 #endif
-typedef	__int64_t	__intmax_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;
 #if defined(__mips_n64) || defined(__mips_n32)
 typedef	__int64_t	__register_t;
 typedef	__int64_t	f_register_t;
@@ -105,42 +71,20 @@ typedef	__int32_t	__register_t;
 typedef	__int32_t	f_register_t;
 #endif
 #ifdef __mips_n64
-typedef	__int64_t	__ptrdiff_t;
 typedef	__int64_t	__segsz_t;
-typedef	__uint64_t	__size_t;
-typedef	__int64_t	__ssize_t;
-typedef	__uint64_t	__uintfptr_t;
-typedef	__uint64_t	__uintptr_t;
 #else
-typedef	__int32_t	__ptrdiff_t;		/* ptr1 - ptr2 */
 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	__uint32_t	__uintfptr_t;
-typedef	__uint32_t	__uintptr_t;
 #endif
 typedef	__int64_t	__time_t;		/* time()... */
-typedef	__uint64_t	__uintmax_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;
 #if defined(__mips_n64) || defined(__mips_n32)
 typedef	__uint64_t	__u_register_t;
 #else
 typedef	__uint32_t	__u_register_t;
 #endif
-#ifdef __mips_n64
-typedef	__uint64_t	__vm_offset_t;
-typedef	__uint64_t	__vm_size_t;
-#else
-typedef	__uint32_t	__vm_offset_t;
-typedef	__uint32_t	__vm_size_t;
-#endif
 #if defined(__mips_n64) || defined(__mips_n32) /* PHYSADDR_64_BIT */
 typedef	__uint64_t	__vm_paddr_t;
 #else
diff --git a/sys/powerpc/include/_types.h b/sys/powerpc/include/_types.h
index 7915f5627579..f3163ea6d9db 100644
--- a/sys/powerpc/include/_types.h
+++ b/sys/powerpc/include/_types.h
@@ -41,33 +41,8 @@
 #ifndef _MACHINE__TYPES_H_
 #define	_MACHINE__TYPES_H_
 
-#ifndef _SYS_CDEFS_H_
-#error this file needs sys/cdefs.h as a prerequisite
-#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;
-#ifdef __LP64__
-typedef	long			__int64_t;
-typedef	unsigned long		__uint64_t;
-#else
-#ifndef lint
-__extension__
-#endif
-/* LONGLONG */
-typedef	long long		__int64_t;
-#ifndef lint
-__extension__
-#endif
-/* LONGLONG */
-typedef	unsigned long long	__uint64_t;
+#ifndef _SYS__TYPES_H_
+#error do not include this header, use sys/_types.h
 #endif
 
 /*
@@ -80,66 +55,35 @@ typedef	float		__float_t;
 #endif
 #ifdef __LP64__
 typedef	__int64_t	__critical_t;
-typedef	__int64_t	__intfptr_t;
-typedef	__int64_t	__intptr_t;
 #else
 typedef	__int32_t	__critical_t;
-typedef	__int32_t	__intfptr_t;
-typedef	__int32_t	__intptr_t;
 #endif
-typedef	__int64_t	__intmax_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;
 #ifdef __LP64__
-typedef	__int64_t	__ptrdiff_t;		/* ptr1 - ptr2 */
 typedef	__int64_t	__register_t;
 typedef	__int64_t	__segsz_t;		/* segment size (in pages) */
-typedef	__uint64_t	__size_t;		/* sizeof() */
-typedef	__int64_t	__ssize_t;		/* byte count or error */
 #else
-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 */
 #endif
 typedef	__int64_t	__time_t;		/* time()... */
-#ifdef __LP64__
-typedef	__uint64_t	__uintfptr_t;
-typedef	__uint64_t	__uintptr_t;
-#else
-typedef	__uint32_t	__uintfptr_t;
-typedef	__uint32_t	__uintptr_t;
-#endif
-typedef	__uint64_t	__uintmax_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;
 #ifdef __LP64__
 typedef	__uint64_t	__u_register_t;
-typedef	__uint64_t	__vm_offset_t;
 typedef	__uint64_t	__vm_paddr_t;
-typedef	__uint64_t	__vm_size_t;
 #else
 typedef	__uint32_t	__u_register_t;
-typedef	__uint32_t	__vm_offset_t;
 #ifdef BOOKE
 typedef	__uint64_t	__vm_paddr_t;
 #else
 typedef	__uint32_t	__vm_paddr_t;
 #endif
-typedef	__uint32_t	__vm_size_t;
 #endif
 typedef	int		___wchar_t;
 
diff --git a/sys/riscv/include/_types.h b/sys/riscv/include/_types.h
index 50b80af4c636..a3a8e97b5e92 100644
--- a/sys/riscv/include/_types.h
+++ b/sys/riscv/include/_types.h
@@ -35,22 +35,10 @@
 #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;
-typedef	long			__int64_t;
-typedef	unsigned long		__uint64_t;
-
 /*
  * Standard type definitions.
  */
@@ -60,38 +48,19 @@ typedef	__int64_t	__critical_t;
 typedef	double		__double_t;
 typedef	float		__float_t;
 #endif
-typedef	__int64_t	__intfptr_t;
-typedef	__int64_t	__intmax_t;
-typedef	__int64_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	__int64_t	__ptrdiff_t;		/* ptr1 - ptr2 */
 typedef	__int64_t	__register_t;
 typedef	__int64_t	__segsz_t;		/* segment size (in pages) */
-typedef	__uint64_t	__size_t;		/* sizeof() */
-typedef	__int64_t	__ssize_t;		/* byte count or error */
 typedef	__int64_t	__time_t;		/* time()... */
-typedef	__uint64_t	__uintfptr_t;
-typedef	__uint64_t	__uintmax_t;
-typedef	__uint64_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	__uint64_t	__u_register_t;
-typedef	__uint64_t	__vm_offset_t;
 typedef	__uint64_t	__vm_paddr_t;
-typedef	__uint64_t	__vm_size_t;
 typedef	int		___wchar_t;
 
 #define	__WCHAR_MIN	__INT_MIN	/* min value for a wchar_t */
diff --git a/sys/sys/_types.h b/sys/sys/_types.h
index 020ba025ea98..1669111a437c 100644
--- a/sys/sys/_types.h
+++ b/sys/sys/_types.h
@@ -32,6 +32,84 @@
 #define _SYS__TYPES_H_
 
 #include <sys/cdefs.h>
+
+/*
+ * Basic types upon which most other types are built.
+ *
+ * Note: It would be nice to simply use the compiler-provided __FOO_TYPE__
+ * macros. However, in order to do so we have to check that those match the
+ * previous typedefs 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.
+ */
+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;
+#if __SIZEOF_LONG__ == 8
+typedef	long			__int64_t;
+typedef	unsigned long		__uint64_t;
+#elif __SIZEOF_LONG__ == 4
+__extension__
+typedef	long long		__int64_t;
+__extension__
+typedef	unsigned long long	__uint64_t;
+#else
+#error unsupported long size
+#endif
+
+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	__int64_t	__intmax_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	__uint64_t	__uintmax_t;
+
+#if __SIZEOF_POINTER__ == 8
+typedef	__int64_t	__intptr_t;
+typedef	__int64_t	__intfptr_t;
+typedef	__uint64_t	__uintptr_t;
+typedef	__uint64_t	__uintfptr_t;
+typedef	__uint64_t	__vm_offset_t;
+typedef	__uint64_t	__vm_size_t;
+#elif __SIZEOF_POINTER__ == 4
+typedef	__int32_t	__intptr_t;
+typedef	__int32_t	__intfptr_t;
+typedef	__uint32_t	__uintptr_t;
+typedef	__uint32_t	__uintfptr_t;
+typedef	__uint32_t	__vm_offset_t;
+typedef	__uint32_t	__vm_size_t;
+#else
+#error unsupported pointer size
+#endif
+
+#if __SIZEOF_SIZE_T__ == 8
+typedef	__uint64_t	__size_t;	/* sizeof() */
+typedef	__int64_t	__ssize_t;	/* byte count or error */
+#elif __SIZEOF_SIZE_T__ == 4
+typedef	__uint32_t	__size_t;	/* sizeof() */
+typedef	__int32_t	__ssize_t;	/* byte count or error */
+#else
+#error unsupported size_t size
+#endif
+
+#if __SIZEOF_PTRDIFF_T__ == 8
+typedef	__int64_t	__ptrdiff_t;	/* ptr1 - ptr2 */
+#elif __SIZEOF_PTRDIFF_T__ == 4
+typedef	__int32_t	__ptrdiff_t;	/* ptr1 - ptr2 */
+#else
+#error unsupported ptrdiff_t size
+#endif
+
+/*
+ * Target-dependent type definitions.
+ */
 #include <machine/_types.h>
 
 /*
diff --git a/sys/sys/stddef.h b/sys/sys/stddef.h
index eeff767bbf20..fba87e4b4702 100644
--- a/sys/sys/stddef.h
+++ b/sys/sys/stddef.h
@@ -33,7 +33,7 @@
 
 #include <sys/cdefs.h>
 #include <sys/_null.h>
-#include <machine/_types.h>
+#include <sys/_types.h>
 
 #ifndef _PTRDIFF_T_DECLARED
 typedef	__ptrdiff_t	ptrdiff_t;
diff --git a/sys/x86/include/_types.h b/sys/x86/include/_types.h
index 68dd7eba6ce1..408f833a1218 100644
--- a/sys/x86/include/_types.h
+++ b/sys/x86/include/_types.h
@@ -41,33 +41,14 @@
 #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
 
 #include <machine/_limits.h>
 
 #define __NO_STRICT_ALIGNMENT
 
-/*
- * 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;
-#ifdef	__LP64__
-typedef	long			__int64_t;
-typedef	unsigned long		__uint64_t;
-#else
-__extension__
-typedef	long long		__int64_t;
-__extension__
-typedef	unsigned long long	__uint64_t;
-#endif
-
 /*
  * Standard type definitions.
  */
@@ -78,8 +59,6 @@ typedef	__int64_t	__critical_t;
 typedef	double		__double_t;
 typedef	float		__float_t;
 #endif
-typedef	__int64_t	__intfptr_t;
-typedef	__int64_t	__intptr_t;
 #else
 typedef	unsigned long	__clock_t;
 typedef	__int32_t	__critical_t;
@@ -87,56 +66,30 @@ typedef	__int32_t	__critical_t;
 typedef	long double	__double_t;
 typedef	long double	__float_t;
 #endif
-typedef	__int32_t	__intfptr_t;
-typedef	__int32_t	__intptr_t;
 #endif
-typedef	__int64_t	__intmax_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;
 #ifdef	__LP64__
-typedef	__int64_t	__ptrdiff_t;		/* ptr1 - ptr2 */
 typedef	__int64_t	__register_t;
 typedef	__int64_t	__segsz_t;		/* segment size (in pages) */
-typedef	__uint64_t	__size_t;		/* sizeof() */
-typedef	__int64_t	__ssize_t;		/* byte count or error */
 typedef	__int64_t	__time_t;		/* time()... */
-typedef	__uint64_t	__uintfptr_t;
-typedef	__uint64_t	__uintptr_t;
 #else
-typedef	__int32_t	__ptrdiff_t;
 typedef	__int32_t	__register_t;
 typedef	__int32_t	__segsz_t;
-typedef	__uint32_t	__size_t;
-typedef	__int32_t	__ssize_t;
 typedef	__int32_t	__time_t;
-typedef	__uint32_t	__uintfptr_t;
-typedef	__uint32_t	__uintptr_t;
 #endif
-typedef	__uint64_t	__uintmax_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;
 #ifdef	__LP64__
 typedef	__uint64_t	__u_register_t;
-typedef	__uint64_t	__vm_offset_t;
 typedef	__uint64_t	__vm_paddr_t;
-typedef	__uint64_t	__vm_size_t;
 #else
 typedef	__uint32_t	__u_register_t;
-typedef	__uint32_t	__vm_offset_t;
 typedef	__uint64_t	__vm_paddr_t;
-typedef	__uint32_t	__vm_size_t;
 #endif
 typedef	int		___wchar_t;
 
diff --git a/sys/x86/include/reg.h b/sys/x86/include/reg.h
index f82848192e67..6bfe7aaedd06 100644
--- a/sys/x86/include/reg.h
+++ b/sys/x86/include/reg.h
@@ -39,7 +39,7 @@
 #ifndef _MACHINE_REG_H_
 #define	_MACHINE_REG_H_
 
-#include <machine/_types.h>
+#include <sys/_types.h>
 
 #ifdef __i386__
 /*



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202106141534.15EFY96S073885>