changeset 400:f7919a143fcb

Add some missing types and macros when we do not have inttypes.h or stdint.h
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 03 Mar 2016 14:36:14 +0200
parents edb6b42c5e8a
children 5a2ad6e49bfb
files th_types.h
diffstat 1 files changed, 22 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/th_types.h	Thu Mar 03 14:35:27 2016 +0200
+++ b/th_types.h	Thu Mar 03 14:36:14 2016 +0200
@@ -70,6 +70,8 @@
 #    define PRIx64        "llx"
 #    define PRIi64        "lli"
 #    define PRIo64        "llo"
+typedef long long int		intmax_t;
+typedef unsigned long long int	uintmax_t;
 #  endif
 #  define PRIu_SIZE_T     "u"
 #  define PRId_SSIZE_T    "d"
@@ -77,8 +79,10 @@
 #  ifndef TH_PTRSIZE
 #    define TH_PTRSIZE 32
 #  endif
-#  ifndef UINTPTR_MAX
-#    define UINTPTR_MAX 0xffffffff
+#  ifndef INTPTR_MIN
+#    define INTPTR_MIN    (-0x7fffffffL - 1)
+#    define INTPTR_MAX    ( 0x7fffffffL)
+#    define UINTPTR_MAX   ( 0xffffffffUL)
 #  endif
 #elif TH_ARCH == 64
 #  define TH_ARCH_64BIT    1
@@ -100,13 +104,16 @@
 #  ifndef TH_PTRSIZE
 #    define TH_PTRSIZE 64
 #  endif
-#  ifndef UINTPTR_MAX
-#    define UINTPTR_MAX 0xffffffffffffffff
+#  ifndef INTPTR_MIN
+#    define INTPTR_MIN    (-0x7fffffffffffffffL - 1)
+#    define INTPTR_MAX    ( 0x7fffffffffffffffL)
+#    define UINTPTR_MAX   ( 0xffffffffffffffffUL)
 #  endif
 #else
 #  error Could not determine architecture (32/64bit), please define TH_ARCH=32 or 64
 #endif
 
+
 // Shorthand types
 typedef unsigned long int ulint_t;
 typedef signed long int lint_t;
@@ -151,6 +158,17 @@
 #endif
 
 
+#ifndef HAVE_INT_TYPES
+#if TH_ARCH == 32
+typedef long long int intmax_t;
+typedef unsigned long long int uintmax_t;
+#elif TH_ARCH == 64
+typedef long int intmax_t;
+typedef unsigned long int uintmax_t;
+#endif
+#endif
+
+
 /* This is the character type used in all string-related routines of
  * th_libs. Currently it is set to be equivalent of basetype "char",
  * but under some platforms it may be necessary to use