aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2015-10-14 17:31:51 +0200
committerMattias Andrée <maandree@operamail.com>2015-10-14 17:31:51 +0200
commita6317b3a4beee17bea35572eda5251631855565b (patch)
tree958313675de760677c9b8501b9a24b8d672caf03 /include
parentinfo: limits (diff)
downloadslibc-a6317b3a4beee17bea35572eda5251631855565b.tar.gz
slibc-a6317b3a4beee17bea35572eda5251631855565b.tar.bz2
slibc-a6317b3a4beee17bea35572eda5251631855565b.tar.xz
semiportable integers were added in c99
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'include')
-rw-r--r--include/stdint.h193
1 files changed, 98 insertions, 95 deletions
diff --git a/include/stdint.h b/include/stdint.h
index c814f13..50af12a 100644
--- a/include/stdint.h
+++ b/include/stdint.h
@@ -22,87 +22,89 @@
-#define __NEED_intN_t
-#define __NEED_uintN_t
-#define __NEED_int_leastN_t
-#define __NEED_uint_leastN_t
-#define __NEED_int_fastN_t
-#define __NEED_uint_fastN_t
-#define __NEED_intptr_t
-#define __NEED_uintptr_t
-#define __NEED_intmax_t
-#define __NEED_uintmax_t
-
+#if defined(__C99__)
+# define __NEED_intN_t
+# define __NEED_uintN_t
+# define __NEED_int_leastN_t
+# define __NEED_uint_leastN_t
+# define __NEED_int_fastN_t
+# define __NEED_uint_fastN_t
+# define __NEED_intptr_t
+# define __NEED_uintptr_t
+# define __NEED_intmax_t
+# define __NEED_uintmax_t
+#endif
#include <bits/types.h>
+#if defined(__C99__)
/**
* Macro that ensure that a signed numeral literal
* of at most 8 encoding bits does not overflow.
*/
-#define INT8_C(value) value
+# define INT8_C(value) value
/**
* Macro that ensure that an unsigned numeral literal
* of at most 8 encoding bits does not overflow.
*/
-#define UINT8_C(value) value
+# define UINT8_C(value) value
/**
* Macro that ensure that a signed numeral literal
* of at most 16 encoding bits does not overflow.
*/
-#define INT16_C(value) value
+# define INT16_C(value) value
/**
* Macro that ensure that an unsigned numeral literal
* of at most 16 encoding bits does not overflow.
*/
-#define UINT16_C(value) value ## U
+# define UINT16_C(value) value ## U
/**
* Macro that ensure that a signed numeral literal
* of at most 32 encoding bits does not overflow.
*/
-#if __INT_BIT == 16
-# define INT32_C(value) value ## L
-#else
-# define INT32_C(value) value
-#endif
+# if __INT_BIT == 16
+# define INT32_C(value) value ## L
+# else
+# define INT32_C(value) value
+# endif
/**
* Macro that ensure that an unsigned numeral literal
* of at most 32 encoding bits does not overflow.
*/
-#if __INT_BIT == 16
-# define UINT32_C(value) value ## UL
-#else
-# define UINT32_C(value) value ## U
-#endif
+# if __INT_BIT == 16
+# define UINT32_C(value) value ## UL
+# else
+# define UINT32_C(value) value ## U
+# endif
/**
* Macro that ensure that a signed numeral literal
* of at most 64 encoding bits does not overflow.
*/
-#if __LONG_BIT == 32
-# define INT64_C(value) value ## LL
-#else
-# define INT64_C(value) value ## L
-#endif
+# if __LONG_BIT == 32
+# define INT64_C(value) value ## LL
+# else
+# define INT64_C(value) value ## L
+# endif
/**
* Macro that ensure that an unsigned numeral literal
* of at most 64 encoding bits does not overflow.
*/
-#if __LONG_BIT == 32
-# define UINT64_C(value) value ## ULL
-#else
-# define UINT64_C(value) value ## UL
-#endif
+# if __LONG_BIT == 32
+# define UINT64_C(value) value ## ULL
+# else
+# define UINT64_C(value) value ## UL
+# endif
/**
@@ -110,255 +112,256 @@
* does not overflow, unless there is no scalar integer
* type that can hold it.
*/
-#if __LONG_BIT == __LONG_LONG_BIT
-# define INTMAX_C(value) value ## L
-#else
-# define INTMAX_C(value) value ## LL
-#endif
+# if __LONG_BIT == __LONG_LONG_BIT
+# define INTMAX_C(value) value ## L
+# else
+# define INTMAX_C(value) value ## LL
+# endif
/**
* Macro that ensure that any unsigned numeral literal
* does not overflow, unless there is no scalar integer
* type that can hold it.
*/
-#if __LONG_BIT == __LONG_LONG_BIT
-# define UINTMAX_C(value) value ## UL
-#else
-# define UINTMAX_C(value) value ## ULL
-#endif
+# if __LONG_BIT == __LONG_LONG_BIT
+# define UINTMAX_C(value) value ## UL
+# else
+# define UINTMAX_C(value) value ## ULL
+# endif
/**
* Maximum value of `uint8_t`.
*/
-#define UINT8_MAX (UINT8_C(0xFF))
+# define UINT8_MAX (UINT8_C(0xFF))
/**
* Maximum value of `int8_t`.
*/
-#define INT8_MAX (INT8_C(0x7F))
+# define INT8_MAX (INT8_C(0x7F))
/**
* Minimum value of `int8_t`.
*/
-#define INT8_MIN (-(INT8_MAX) - 1)
+# define INT8_MIN (-(INT8_MAX) - 1)
/**
* Maximum value of `uint16_t`.
*/
-#define UINT16_MAX (UINT16_C(0xFFFF))
+# define UINT16_MAX (UINT16_C(0xFFFF))
/**
* Maximum value of `int16_t`.
*/
-#define INT16_MAX (INT16_C(0x7FFF))
+# define INT16_MAX (INT16_C(0x7FFF))
/**
* Minimum value of `int16_t`.
*/
-#define INT16_MIN (-(INT16_MAX) - 1)
+# define INT16_MIN (-(INT16_MAX) - 1)
/**
* Maximum value of `uint32_t`.
*/
-#define UINT32_MAX (UINT32_C(0xFFFFFFFF))
+# define UINT32_MAX (UINT32_C(0xFFFFFFFF))
/**
* Maximum value of `int32_t`.
*/
-#define INT32_MAX (INT32_C(0x7FFFFFFF))
+# define INT32_MAX (INT32_C(0x7FFFFFFF))
/**
* Minimum value of `int32_t`.
*/
-#define INT32_MIN (-(INT32_MAX) - 1)
+# define INT32_MIN (-(INT32_MAX) - 1)
/**
* Maximum value of `uint64_t`.
*/
-#define UINT64_MAX (UINT64_C(0xFFFFFFFFFFFFFFFF))
+# define UINT64_MAX (UINT64_C(0xFFFFFFFFFFFFFFFF))
/**
* Maximum value of `int64_t`.
*/
-#define INT64_MAX (INT64_C(0x7FFFFFFFFFFFFFFF))
+# define INT64_MAX (INT64_C(0x7FFFFFFFFFFFFFFF))
/**
* Minimum value of `int64_t`.
*/
-#define INT64_MIN (-(INT64_MAX) - 1)
+# define INT64_MIN (-(INT64_MAX) - 1)
/**
* Maximum value of `uint_least8_t`.
*/
-#define UINT_LEAST8_MAX UINT8_MAX
+# define UINT_LEAST8_MAX UINT8_MAX
/**
* Maximum value of `int_least8_t`.
*/
-#define INT_LEAST8_MAX INT8_MAX
+# define INT_LEAST8_MAX INT8_MAX
/**
* Minimum value of `int_least8_t`.
*/
-#define INT_LEAST8_MIN (__MAX_TO_MIN(INT_LEAST8_MAX))
+# define INT_LEAST8_MIN (__MAX_TO_MIN(INT_LEAST8_MAX))
/**
* Maximum value of `uint_least16_t`.
*/
-#define UINT_LEAST16_MAX UINT16_MAX
+# define UINT_LEAST16_MAX UINT16_MAX
/**
* Maximum value of `int_least16_t`.
*/
-#define INT_LEAST16_MAX INT16_MAX
+# define INT_LEAST16_MAX INT16_MAX
/**
* Minimum value of `int_least16_t`.
*/
-#define INT_LEAST16_MIN (__MAX_TO_MIN(INT_LEAST16_MAX))
+# define INT_LEAST16_MIN (__MAX_TO_MIN(INT_LEAST16_MAX))
/**
* Maximum value of `uint_least32_t`.
*/
-#define UINT_LEAST32_MAX UINT32_MAX
+# define UINT_LEAST32_MAX UINT32_MAX
/**
* Maximum value of `int_least32_t`.
*/
-#define INT_LEAST32_MAX INT32_MAX
+# define INT_LEAST32_MAX INT32_MAX
/**
* Minimum value of `int_least32_t`.
*/
-#define INT_LEAST32_MIN (__MAX_TO_MIN(INT_LEAST32_MAX))
+# define INT_LEAST32_MIN (__MAX_TO_MIN(INT_LEAST32_MAX))
/**
* Maximum value of `uint_least64_t`.
*/
-#define UINT_LEAST64_MAX UINT64_MAX
+# define UINT_LEAST64_MAX UINT64_MAX
/**
* Maximum value of `int_least64_t`.
*/
-#define INT_LEAST64_MAX INT64_MAX
+# define INT_LEAST64_MAX INT64_MAX
/**
* Minimum value of `int_least64_t`.
*/
-#define INT_LEAST64_MIN (__MAX_TO_MIN(INT_LEAST64_MAX))
+# define INT_LEAST64_MIN (__MAX_TO_MIN(INT_LEAST64_MAX))
/**
* Maximum value of `uint_fast8_t`.
*/
-#define UINT_FAST8_MAX __UINT_FAST8_MAX
+# define UINT_FAST8_MAX __UINT_FAST8_MAX
/**
* Maximum value of `int_fast8_t`.
*/
-#define INT_FAST8_MAX __INT_FAST8_MAX
+# define INT_FAST8_MAX __INT_FAST8_MAX
/**
* Minimum value of `int_fast8_t`.
*/
-#define INT_FAST8_MIN (__MAX_TO_MIN(INT_FAST8_MAX))
+# define INT_FAST8_MIN (__MAX_TO_MIN(INT_FAST8_MAX))
/**
* Maximum value of `uint_fast16_t`.
*/
-#define UINT_FAST16_MAX __UINT_FAST16_MAX
+# define UINT_FAST16_MAX __UINT_FAST16_MAX
/**
* Maximum value of `int_fast16_t`.
*/
-#define INT_FAST16_MAX __INT_FAST16_MAX
+# define INT_FAST16_MAX __INT_FAST16_MAX
/**
* Minimum value of `int_fast16_t`.
*/
-#define INT_FAST16_MIN (__MAX_TO_MIN(INT_FAST16_MAX))
+# define INT_FAST16_MIN (__MAX_TO_MIN(INT_FAST16_MAX))
/**
* Maximum value of `uint_fast32_t`.
*/
-#define UINT_FAST32_MAX __UINT_FAST32_MAX
+# define UINT_FAST32_MAX __UINT_FAST32_MAX
/**
* Maximum value of `int_fast32_t`.
*/
-#define INT_FAST32_MAX __INT_FAST32_MAX
+# define INT_FAST32_MAX __INT_FAST32_MAX
/**
* Minimum value of `int_fast32_t`.
*/
-#define INT_FAST32_MIN (__MAX_TO_MIN(INT_FAST32_MAX))
+# define INT_FAST32_MIN (__MAX_TO_MIN(INT_FAST32_MAX))
/**
* Maximum value of `uint_fast64_t`.
*/
-#define UINT_FAST64_MAX __UINT_FAST64_MAX
+# define UINT_FAST64_MAX __UINT_FAST64_MAX
/**
* Maximum value of `int_fast64_t`.
*/
-#define INT_FAST64_MAX __INT_FAST64_MAX
+# define INT_FAST64_MAX __INT_FAST64_MAX
/**
* Minimum value of `int_fast64_t`.
*/
-#define INT_FAST64_MIN (__MAX_TO_MIN(INT_FAST64_MAX))
+# define INT_FAST64_MIN (__MAX_TO_MIN(INT_FAST64_MAX))
/**
* Maximum value of `uintmax_t`.
*/
-#define UINTMAX_MAX __UINTMAX_MAX
+# define UINTMAX_MAX __UINTMAX_MAX
/**
* Maximum value of `intmax_t`.
*/
-#define INTMAX_MAX __INTMAX_MAX
+# define INTMAX_MAX __INTMAX_MAX
/**
* Minimum value of `intmax_t`.
*/
-#define INTMAX_MIN (__MAX_TO_MIN(INTMAX_MIN))
+# define INTMAX_MIN (__MAX_TO_MIN(INTMAX_MIN))
/**
* Maximum value of `uintptr_t`.
*/
-#if __LONG_BIT == 32
-# define UINTPTR_MAX UINT32_MAX
-#else
-# define UINTPTR_MAX UINT64_MAX
-#endif
+# if __LONG_BIT == 32
+# define UINTPTR_MAX UINT32_MAX
+# else
+# define UINTPTR_MAX UINT64_MAX
+# endif
/**
* Maximum value of `intptr_t`.
*/
-#if __LONG_BIT == 32
-# define INTPTR_MAX INT32_MAX
-#else
-# define INTPTR_MAX INT64_MAX
-#endif
+# if __LONG_BIT == 32
+# define INTPTR_MAX INT32_MAX
+# else
+# define INTPTR_MAX INT64_MAX
+# endif
/**
* Minimum value of `intptr_t`.
*/
-#define INTPTR_MIN (__MAX_TO_MIN(INTPTR_MAX))
+# define INTPTR_MIN (__MAX_TO_MIN(INTPTR_MAX))
+#endif
/**