# HG changeset patch # User Matti Hamalainen # Date 1578597099 -7200 # Node ID c054e5831dfb0816178ca0fd230fa3f350b3e4e1 # Parent ac2947ac9ef82d8a256015ffc230411dcc56ce4e Clean up the th_types.h header #ifdef mess slightly. diff -r ac2947ac9ef8 -r c054e5831dfb th_types.h --- 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