# HG changeset patch # User Matti Hamalainen # Date 1457008574 -7200 # Node ID f7919a143fcbd4b95879a619d9db9527dfe7bc3d # Parent edb6b42c5e8a901c5478dfda3c7d59ecff7119f1 Add some missing types and macros when we do not have inttypes.h or stdint.h diff -r edb6b42c5e8a -r f7919a143fcb th_types.h --- 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