aboutsummaryrefslogtreecommitdiff
path: root/lib/libc/include/stdint.h
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2024-03-15 22:18:45 -0400
committerIan Moffett <ian@osmora.org>2024-03-15 22:18:45 -0400
commitdf5b897d7a2c023b73717354832d1ea2f8bc10e6 (patch)
tree7b0c470383d36bb89f671ce8c758f86a9e53f11a /lib/libc/include/stdint.h
parent23562f3f6ecfcf2ae83c4017ad931629ad16efa6 (diff)
libc: Reimplement stdint.h
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'lib/libc/include/stdint.h')
-rw-r--r--lib/libc/include/stdint.h85
1 files changed, 20 insertions, 65 deletions
diff --git a/lib/libc/include/stdint.h b/lib/libc/include/stdint.h
index 2fb0752..ed6aa08 100644
--- a/lib/libc/include/stdint.h
+++ b/lib/libc/include/stdint.h
@@ -30,78 +30,33 @@
#ifndef _STDINT_H
#define _STDINT_H
+#include <bits/_types.h>
+
#if defined(__cplusplus)
extern "C" {
#endif
-#if defined(__GNUC__) && \
- ( (__GNUC__ >= 4) || \
- ( (__GNUC__ >= 3) && defined(__GNUC_MINOR__) && (__GNUC_MINOR__ > 2) ) )
-#define __STDINT_EXP(x) __##x##__
-#else
-#define __STDINT_EXP(x) x
-#include <limits.h>
-#endif
-
-#if __STDINT_EXP(SCHAR_MAX) == 0x7f
-typedef signed char int8_t ;
-typedef unsigned char uint8_t ;
-#define __int8_t_defined 1
-#endif
-
-#if __STDINT_EXP(SHRT_MAX) == 0x7fff
-typedef signed short int16_t;
-typedef unsigned short uint16_t;
-#define __int16_t_defined 1
-#elif __STDINT_EXP(INT_MAX) == 0x7fff
-typedef signed int int16_t;
-typedef unsigned int uint16_t;
-#define __int16_t_defined 1
-#elif __STDINT_EXP(SCHAR_MAX) == 0x7fff
-typedef signed char int16_t;
-typedef unsigned char uint16_t;
-#define __int16_t_defined 1
-#endif
+typedef __uint8_t uint8_t;
+typedef __uint16_t uint16_t;
+typedef __uint32_t uint32_t;
+typedef __uint64_t uint64_t;
-#if __have_long32
-typedef signed long int32_t;
-typedef unsigned long uint32_t;
-#define __int32_t_defined 1
-#elif __STDINT_EXP(INT_MAX) == 0x7fffffffL
-typedef signed int int32_t;
-typedef unsigned int uint32_t;
-#define __int32_t_defined 1
-#elif __STDINT_EXP(SHRT_MAX) == 0x7fffffffL
-typedef signed short int32_t;
-typedef unsigned short uint32_t;
-#define __int32_t_defined 1
-#elif __STDINT_EXP(SCHAR_MAX) == 0x7fffffffL
-typedef signed char int32_t;
-typedef unsigned char uint32_t;
-#define __int32_t_defined 1
-#endif
+typedef __int8_t int8_t;
+typedef __int16_t int16_t;
+typedef __int32_t int32_t;
+typedef __int64_t int64_t;
-#if __SIZEOF_SIZE_T__ == 8
-typedef unsigned long long uint64_t;
-#endif
+/* Signed fixed-width limits */
+#define INT8_MAX __INT8_MAX
+#define INT16_MAX __INT16_MAX
+#define INT32_MAX __INT32_MAX
+#define INT64_MAX __INT64_MAX
-#if defined(__PTRDIFF_TYPE__)
-typedef signed __PTRDIFF_TYPE__ intptr_t;
-typedef unsigned __PTRDIFF_TYPE__ uintptr_t;
-#define INTPTR_MAX PTRDIFF_MAX
-#define INTPTR_MIN PTRDIFF_MIN
-#ifdef __UINTPTR_MAX__
-#define UINTPTR_MAX __UINTPTR_MAX__
-#else
-#define UINTPTR_MAX (2UL * PTRDIFF_MAX + 1)
-#endif
-#else
-typedef signed long intptr_t;
-typedef unsigned long uintptr_t;
-#define INTPTR_MAX __STDINT_EXP(LONG_MAX)
-#define INTPTR_MIN (-__STDINT_EXP(LONG_MAX) - 1)
-#define UINTPTR_MAX (__STDINT_EXP(LONG_MAX) * 2UL + 1)
-#endif
+/* Unsigned fixed-width limits */
+#define UINT8_MAX __UINT8_MAX
+#define UINT16_MAX __UINT16_MAX
+#define UINT32_MAX __UINT32_MAX
+#define UINT64_MAX __UINT64_MAX
#if defined(__cplusplus)
}