changeset 579:c054e5831dfb

Clean up the th_types.h header #ifdef mess slightly.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 09 Jan 2020 21:11:39 +0200
parents ac2947ac9ef8
children 4d12924f9544
files th_types.h
diffstat 1 files changed, 30 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/th_types.h	Thu Jan 09 18:29:10 2020 +0200
+++ b/th_types.h	Thu Jan 09 21:11:39 2020 +0200
@@ -36,7 +36,6 @@
 #endif
 
 
-
 // Check for arch bitness
 #if !defined(TH_ARCH) && (defined(__WIN64) || defined(_WIN64))
 #  define TH_ARCH 64
@@ -63,11 +62,11 @@
 #  endif
 #endif
 
+
 // Do we have a valid arch?
-// If so, set some printf specifiers and other useful things
-#if TH_ARCH == 32
-#  ifndef HAVE_INTTYPES_H
-//   If we don't have ISO C99 inttypes.h, define PRI* macros
+// If we don't have ISO C99 inttypes.h, define PRI* macros
+#ifndef HAVE_INTTYPES_H
+#  if TH_ARCH == 32
 #    define PRIu32        "u"
 #    define PRId32        "d"
 #    define PRIx32        "x"
@@ -78,20 +77,7 @@
 #    define PRIx64        "llx"
 #    define PRIi64        "lli"
 #    define PRIo64        "llo"
-#  endif
-#  define PRIu_SIZE_T     PRIu32
-#  define PRId_SSIZE_T    PRId32
-#  define PRIx_SIZE_T     PRIx32
-#  ifndef TH_PTRSIZE
-#    define TH_PTRSIZE 32
-#  endif
-#  ifndef INTPTR_MIN
-#    define INTPTR_MIN    (-0x7fffffffL - 1)
-#    define INTPTR_MAX    ( 0x7fffffffL)
-#    define UINTPTR_MAX   ( 0xffffffffUL)
-#  endif
-#elif TH_ARCH == 64
-#  ifndef HAVE_INTTYPES_H
+#  elif TH_ARCH == 64
 #    define PRIu32        "u"
 #    define PRId32        "d"
 #    define PRIx32        "x"
@@ -102,10 +88,35 @@
 #    define PRIx64        "lx"
 #    define PRIi64        "li"
 #    define PRIo64        "lo"
+#  else
+#    error Could not determine architecture (32/64bit), please define TH_ARCH=32 or 64
 #  endif
+#endif
+
+
+// Define some printf specifiers and other useful things
+#if TH_ARCH == 32
+#  define PRIu_SIZE_T     PRIu32
+#  define PRId_SSIZE_T    PRId32
+#  define PRIx_SIZE_T     PRIx32
+#  define PRIu_OFF_T      PRIu32
+#  define PRIx_OFF_T      PRId32
+#  define PRIX_OFF_T      PRIx32
+#  ifndef TH_PTRSIZE
+#    define TH_PTRSIZE 32
+#  endif
+#  ifndef INTPTR_MIN
+#    define INTPTR_MIN    (-0x7fffffffL - 1)
+#    define INTPTR_MAX    ( 0x7fffffffL)
+#    define UINTPTR_MAX   ( 0xffffffffUL)
+#  endif
+#elif TH_ARCH == 64
 #  define PRIu_SIZE_T     PRIu64
 #  define PRId_SSIZE_T    PRId64
 #  define PRIx_SIZE_T     PRIx64
+#  define PRIu_OFF_T      PRIu64
+#  define PRIx_OFF_T      PRId64
+#  define PRIX_OFF_T      PRIx64
 #  ifndef TH_PTRSIZE
 #    define TH_PTRSIZE 64
 #  endif
@@ -114,8 +125,6 @@
 #    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