From 123e2fab97632347f07c361589e6c586d38df2ee Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Mon, 20 Jun 2011 21:30:39 -0700 Subject: [PATCH] lib: sync and from klibc The stdint.h definition appears to be a total mess. Clean it up with the current version from klibc, and revert change of size_t being long rather than int (it is not on i386). Signed-off-by: H. Peter Anvin --- com32/include/bitsize/stddef.h | 2 +- com32/include/bitsize/stdint.h | 68 ++++----- com32/include/bitsize/stdintconst.h | 2 +- com32/include/bitsize/stdintlimits.h | 2 +- com32/include/stdint.h | 266 +++++++++++++++-------------------- 5 files changed, 153 insertions(+), 187 deletions(-) rewrite com32/include/bitsize/stdint.h (66%) rewrite com32/include/stdint.h (95%) diff --git a/com32/include/bitsize/stddef.h b/com32/include/bitsize/stddef.h index bba48cf7..213e8ab7 100644 --- a/com32/include/bitsize/stddef.h +++ b/com32/include/bitsize/stddef.h @@ -6,7 +6,7 @@ #define _BITSIZE_STDDEF_H #define _SIZE_T -typedef unsigned long size_t; +typedef unsigned int size_t; #define _PTRDIFF_T typedef signed long ptrdiff_t; diff --git a/com32/include/bitsize/stdint.h b/com32/include/bitsize/stdint.h dissimilarity index 66% index 8cbfc5dd..8e444b6d 100644 --- a/com32/include/bitsize/stdint.h +++ b/com32/include/bitsize/stdint.h @@ -1,34 +1,34 @@ -/* - * bits32/stdint.h - */ - -#ifndef _BITSIZE_STDINT_H -#define _BITSIZE_STDINT_H - -typedef signed char int8_t; -typedef short int int16_t; -typedef int int32_t; -typedef long long int int64_t; - -typedef unsigned char uint8_t; -typedef unsigned short int uint16_t; -typedef unsigned int uint32_t; -typedef unsigned long long int uint64_t; - -typedef int int_fast16_t; -typedef int int_fast32_t; - -typedef unsigned int uint_fast16_t; -typedef unsigned int uint_fast32_t; - -typedef int intptr_t; -typedef unsigned int uintptr_t; - -#define __INT64_C(c) c ## LL -#define __UINT64_C(c) c ## ULL - -#define __PRI64_RANK "ll" -#define __PRIFAST_RANK "" -#define __PRIPTR_RANK "" - -#endif /* _BITSIZE_STDINT_H */ +/* + * bits32/stdint.h + */ + +#ifndef _BITSIZE_STDINT_H +#define _BITSIZE_STDINT_H + +typedef signed char int8_t; +typedef short int int16_t; +typedef int int32_t; +typedef long long int int64_t; + +typedef unsigned char uint8_t; +typedef unsigned short int uint16_t; +typedef unsigned int uint32_t; +typedef unsigned long long int uint64_t; + +typedef int int_fast16_t; +typedef int int_fast32_t; + +typedef unsigned int uint_fast16_t; +typedef unsigned int uint_fast32_t; + +typedef int intptr_t; +typedef unsigned int uintptr_t; + +#define __INT64_C(c) c ## LL +#define __UINT64_C(c) c ## ULL + +#define __PRI64_RANK "ll" +#define __PRIFAST_RANK "" +#define __PRIPTR_RANK "" + +#endif /* _BITSIZE_STDINT_H */ diff --git a/com32/include/bitsize/stdintconst.h b/com32/include/bitsize/stdintconst.h index 8157dd06..7db63bdf 100644 --- a/com32/include/bitsize/stdintconst.h +++ b/com32/include/bitsize/stdintconst.h @@ -15,4 +15,4 @@ #define UINTPTR_C(c) UINT32_C(c) #define PTRDIFF_C(c) INT32_C(c) -#endif /* _BITSIZE_STDINTCONST_H */ +#endif /* _BITSIZE_STDINTCONST_H */ diff --git a/com32/include/bitsize/stdintlimits.h b/com32/include/bitsize/stdintlimits.h index b44fe011..d85094d9 100644 --- a/com32/include/bitsize/stdintlimits.h +++ b/com32/include/bitsize/stdintlimits.h @@ -19,4 +19,4 @@ #define PTRDIFF_MIN INT32_MIN #define PTRDIFF_MAX INT32_MAX -#endif /* _BITSIZE_STDINTLIMITS_H */ +#endif /* _BITSIZE_STDINTLIMITS_H */ diff --git a/com32/include/stdint.h b/com32/include/stdint.h dissimilarity index 95% index a0ebbced..f64f0278 100644 --- a/com32/include/stdint.h +++ b/com32/include/stdint.h @@ -1,150 +1,116 @@ -/* - * stdint.h - */ - -#ifndef _STDINT_H -#define _STDINT_H - -/* Exact types */ - -typedef signed char int8_t; -typedef signed short int16_t; -typedef signed int int32_t; -typedef signed long long int64_t; - -typedef unsigned char uint8_t; -typedef unsigned short uint16_t; -typedef unsigned int uint32_t; -typedef unsigned long long uint64_t; - -/* Small types */ - -typedef signed char int_least8_t; -typedef signed short int_least16_t; -typedef signed int int_least32_t; -typedef signed long long int_least64_t; - -typedef unsigned char uint_least8_t; -typedef unsigned short uint_least16_t; -typedef unsigned int uint_least32_t; -typedef unsigned long long uint_least64_t; - -/* Fast types */ - -typedef signed char int_fast8_t; -typedef signed short int_fast16_t; -typedef signed int int_fast32_t; -typedef signed long long int_fast64_t; - -typedef unsigned char uint_fast8_t; -typedef unsigned short uint_fast16_t; -typedef unsigned int uint_fast32_t; -typedef unsigned long long uint_fast64_t; - -/* Pointer types */ - -typedef signed long intptr_t; -typedef unsigned long uintptr_t; - -/* Maximal types */ - -typedef int64_t intmax_t; -typedef uint64_t uintmax_t; - -/* Rank definitions, used in inttypes.h */ -#define __PRIFAST_RANK "" -#define __SCNFAST_RANK "" -#define __PRIPTR_RANK "l" -#define __SCNPTR_RANK "l" -#define __PRI64_RANK "ll" -#define __SCN64_RANK "ll" - -/* - * To be strictly correct... - */ -#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) - -# define INT8_MIN (-128) -# define INT16_MIN (-32767-1) -# define INT32_MIN (-2147483647-1) -# define INT64_MIN (-9223372036854775807LL-1) - -# define INT8_MAX (127) -# define INT16_MAX (32767) -# define INT32_MAX (2147483647) -# define INT64_MAX (9223372036854775807LL) - -# define UINT8_MAX (255U) -# define UINT16_MAX (65535U) -# define UINT32_MAX (4294967295U) -# define UINT64_MAX (18446744073709551615ULL) - -# define INT_LEAST8_MIN (-128) -# define INT_LEAST16_MIN (-32767-1) -# define INT_LEAST32_MIN (-2147483647-1) -# define INT_LEAST64_MIN (-9223372036854775807LL-1) - -# define INT_LEAST8_MAX (127) -# define INT_LEAST16_MAX (32767) -# define INT_LEAST32_MAX (2147483647) -# define INT_LEAST64_MAX (9223372036854775807LL) - -# define UINT_LEAST8_MAX (255U) -# define UINT_LEAST16_MAX (65535U) -# define UINT_LEAST32_MAX (4294967295U) -# define UINT_LEAST64_MAX (18446744073709551615ULL) - -# define INT_FAST8_MIN (-128) -# define INT_FAST16_MIN (-32767-1) -# define INT_FAST32_MIN (-2147483647-1) -# define INT_FAST64_MIN (-9223372036854775807LL-1) - -# define INT_FAST8_MAX (127) -# define INT_FAST16_MAX (32767) -# define INT_FAST32_MAX (2147483647) -# define INT_FAST64_MAX (9223372036854775807LL) - -# define UINT_FAST8_MAX (255U) -# define UINT_FAST16_MAX (65535U) -# define UINT_FAST32_MAX (4294967295U) -# define UINT_FAST64_MAX (18446744073709551615ULL) - -# define INTPTR_MIN (-2147483647-1) -# define INTPTR_MAX (2147483647) -# define UINTPTR_MAX (4294967295U) - -# define INTMAX_MIN (-9223372036854775807LL-1) -# define INTMAX_MAX (9223372036854775807LL) -# define UINTMAX_MAX (18446744073709551615ULL) - -/* ptrdiff_t limit */ -# define PTRDIFF_MIN (-2147483647-1) -# define PTRDIFF_MAX (2147483647) - -/* sig_atomic_t limit */ -# define SIG_ATOMIC_MIN (-2147483647-1) -# define SIG_ATOMIC_MAX (2147483647) - -/* size_t limit */ -# define SIZE_MAX (4294967295U) - -#endif /* STDC_LIMIT_MACROS */ - -#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) - -# define INT8_C(n) n -# define INT16_C(n) n -# define INT32_C(n) n -# define INT64_C(n) n ## LL - -# define UINT8_C(n) n ## U -# define UINT16_C(n) n ## U -# define UINT32_C(n) n ## U -# define UINT64_C(n) n ## ULL - -# define INTMAX_C(n) n ## LL -# define UINTMAX_C(n) n ## ULL - -#endif /* STDC_CONSTANT_MACROS */ - -#endif /* _STDINT_H */ +/* + * stdint.h + */ + +#ifndef _STDINT_H +#define _STDINT_H + +#include + +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 uint8_t uint_least8_t; +typedef uint16_t uint_least16_t; +typedef uint32_t uint_least32_t; +typedef uint64_t uint_least64_t; + +typedef int8_t int_fast8_t; +typedef int64_t int_fast64_t; + +typedef uint8_t uint_fast8_t; +typedef uint64_t uint_fast64_t; + +typedef int64_t intmax_t; +typedef uint64_t uintmax_t; + +#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) + +#define INT8_MIN (-128) +#define INT16_MIN (-32768) +#define INT32_MIN (-2147483647-1) +#define INT64_MIN (__INT64_C(-9223372036854775807)-1) + +#define INT8_MAX (127) +#define INT16_MAX (32767) +#define INT32_MAX (2147483647) +#define INT64_MAX (__INT64_C(9223372036854775807)) + +#define UINT8_MAX (255U) +#define UINT16_MAX (65535U) +#define UINT32_MAX (4294967295U) +#define UINT64_MAX (__UINT64_C(18446744073709551615)) + +#define INT_LEAST8_MIN INT8_MIN +#define INT_LEAST16_MIN INT16_MIN +#define INT_LEAST32_MIN INT32_MIN +#define INT_LEAST64_MIN INT64_MIN + +#define INT_LEAST8_MAX INT8_MAX +#define INT_LEAST16_MAX INT16_MAX +#define INT_LEAST32_MAX INT32_MAX +#define INT_LEAST64_MAX INT64_MAX + +#define UINT_LEAST8_MAX UINT8_MAX +#define UINT_LEAST16_MAX UINT16_MAX +#define UINT_LEAST32_MAX UINT32_MAX +#define UINT_LEAST64_MAX UINT64_MAX + +#define INT_FAST8_MIN INT8_MIN +#define INT_FAST64_MIN INT64_MIN + +#define INT_FAST8_MAX INT8_MAX +#define INT_FAST64_MAX INT64_MAX + +#define UINT_FAST8_MAX UINT8_MAX +#define UINT_FAST64_MAX UINT64_MAX + +#define INTMAX_MIN INT64_MIN +#define INTMAX_MAX INT64_MAX +#define UINTMAX_MAX UINT64_MAX + +#include + +#endif + +#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) + +#define INT8_C(c) c +#define INT16_C(c) c +#define INT32_C(c) c +#define INT64_C(c) __INT64_C(c) + +#define UINT8_C(c) c ## U +#define UINT16_C(c) c ## U +#define UINT32_C(c) c ## U +#define UINT64_C(c) __UINT64_C(c) + +#define INT_LEAST8_C(c) INT8_C(c) +#define INT_LEAST16_C(c) INT16_C(c) +#define INT_LEAST32_C(c) INT32_C(c) +#define INT_LEAST64_C(c) INT64_C(c) + +#define UINT_LEAST8_C(c) UINT8_C(c) +#define UINT_LEAST16_C(c) UINT16_C(c) +#define UINT_LEAST32_C(c) UINT32_C(c) +#define UINT_LEAST64_C(c) UINT64_C(c) + +#define INT_FAST8_C(c) INT8_C(c) +#define INT_FAST64_C(c) INT64_C(c) + +#define UINT_FAST8_C(c) UINT8_C(c) +#define UINT_FAST64_C(c) UINT64_C(c) + +#define INTMAX_C(c) INT64_C(c) +#define UINTMAX_C(c) UINT64_C(c) + +#include + +#endif + +/* Keep the kernel from trying to define these types... */ +#define __BIT_TYPES_DEFINED__ + +#endif /* _STDINT_H */ -- 2.11.4.GIT