diff --git a/dtool/Config.FreeBSD.pp b/dtool/Config.FreeBSD.pp index f5059c3737..9a96e106ca 100644 --- a/dtool/Config.FreeBSD.pp +++ b/dtool/Config.FreeBSD.pp @@ -278,6 +278,9 @@ // Do we have ? This enables us to use raw mouse input. #define PHAVE_LINUX_INPUT_H +// Do we have ? +#define PHAVE_STDINT_H 1 + // Do we have RTTI (and )? #define HAVE_RTTI 1 diff --git a/dtool/Config.Irix.pp b/dtool/Config.Irix.pp index 1df3658246..6522228c2d 100644 --- a/dtool/Config.Irix.pp +++ b/dtool/Config.Irix.pp @@ -137,6 +137,9 @@ // interface)? #define PHAVE_SYS_SOUNDCARD_H +// Do we have ? +#define PHAVE_STDINT_H + // Do we have RTTI (and )? #define HAVE_RTTI 1 diff --git a/dtool/Config.Linux.pp b/dtool/Config.Linux.pp index d657805fef..7d42e0a92f 100644 --- a/dtool/Config.Linux.pp +++ b/dtool/Config.Linux.pp @@ -324,6 +324,9 @@ // Do we have RTTI (and )? #define HAVE_RTTI 1 +// Do we have ? +#define PHAVE_STDINT_H 1 + // We need 64-bit file i/o #define __USE_LARGEFILE64 1 diff --git a/dtool/Config.OSX.pp b/dtool/Config.OSX.pp index 5c9ee091fc..dd935c8d03 100644 --- a/dtool/Config.OSX.pp +++ b/dtool/Config.OSX.pp @@ -281,6 +281,9 @@ // definitions. #define USE_STL_ALLOCATOR 1 +// Do we have ? +#define PHAVE_STDINT_H 1 + // The dynamic library file extension (usually .so .dll or .dylib): #define DYNAMIC_LIB_EXT .dylib #define STATIC_LIB_EXT .a diff --git a/dtool/Config.Win32.pp b/dtool/Config.Win32.pp index 3e021af5b5..f6344844bc 100644 --- a/dtool/Config.Win32.pp +++ b/dtool/Config.Win32.pp @@ -157,6 +157,9 @@ // Do we have RTTI (and )? #define HAVE_RTTI 1 +// Do we have ? +#define PHAVE_STDINT_H + // MSVC7 does support the latest STL allocator definitions. #define USE_STL_ALLOCATOR 1 diff --git a/dtool/LocalSetup.pp b/dtool/LocalSetup.pp index c2eead2171..d4b9958db2 100644 --- a/dtool/LocalSetup.pp +++ b/dtool/LocalSetup.pp @@ -626,6 +626,9 @@ $[cdefine PHAVE_UCONTEXT_H] /* Do we have ? This enables us to use raw mouse input. */ $[cdefine PHAVE_LINUX_INPUT_H] +/* Do we have ? */ +$[cdefine PHAVE_STDINT_H] + /* Do we have RTTI (and )? */ $[cdefine HAVE_RTTI] diff --git a/dtool/src/dtoolbase/dtoolbase.h b/dtool/src/dtoolbase/dtoolbase.h index 1fea41040d..30bfe3d4d7 100644 --- a/dtool/src/dtoolbase/dtoolbase.h +++ b/dtool/src/dtoolbase/dtoolbase.h @@ -162,6 +162,10 @@ #include #endif +#ifdef PHAVE_STDINT_H +#include +#endif + #ifdef CPPPARSER #include #endif @@ -289,7 +293,9 @@ /* Try to determine if we're compiling in a 64-bit mode. */ -#if defined(_LP64) +#ifdef __WORDSIZE +#define NATIVE_WORDSIZE __WORDSIZE +#elif defined(_LP64) #define NATIVE_WORDSIZE 64 #else #define NATIVE_WORDSIZE 32 diff --git a/dtool/src/dtoolbase/numeric_types.h b/dtool/src/dtoolbase/numeric_types.h index 1a6c19198f..d40725b14c 100644 --- a/dtool/src/dtoolbase/numeric_types.h +++ b/dtool/src/dtoolbase/numeric_types.h @@ -21,47 +21,56 @@ // the various numeric types for unsigned and signed numbers of // various widths. -#if defined(_LP64) -// A 64-bit environment. - -typedef signed char PN_int8; -typedef short PN_int16; -typedef int PN_int32; - -typedef unsigned char PN_uint8; -typedef unsigned short PN_uint16; -typedef unsigned int PN_uint32; -typedef long PN_int64; -typedef unsigned long PN_uint64; - -typedef double PN_float64; -typedef float PN_float32; - -#else // _LP64 -// A 32-bit environment. - -typedef signed char PN_int8; -typedef short PN_int16; -typedef int PN_int32; - -typedef unsigned char PN_uint8; -typedef unsigned short PN_uint16; -typedef unsigned int PN_uint32; - #ifdef WIN32_VC -typedef __int64 PN_int64; +typedef signed __int8 PN_int8; +typedef signed __int16 PN_int16; +typedef signed __int32 PN_int32; +typedef signed __int64 PN_int64; + +typedef unsigned __int8 PN_uint8; +typedef unsigned __int16 PN_uint16; +typedef unsigned __int32 PN_uint32; typedef unsigned __int64 PN_uint64; + +#elif defined(PHAVE_STDINT_H) + +#include + +typedef int8_t PN_int8; +typedef int16_t PN_int16; +typedef int32_t PN_int32; +typedef int64_t PN_int64; + +typedef uint8_t PN_uint8; +typedef uint16_t PN_uint16; +typedef uint32_t PN_uint32; +typedef uint64_t PN_uint64; + #else -typedef long long PN_int64; -typedef unsigned long long PN_uint64; + +// This is risky, but we have no other choice. +typedef signed char PN_int8; +typedef short int PN_int16; +typedef int PN_int32; +#if NATIVE_WORDSIZE == 64 +typedef long int PN_int64; +#else +typedef long long int PN_int64; +#endif + +typedef unsigned char PN_uint8; +typedef unsigned short int PN_uint16; +typedef unsigned int PN_uint32; +#if NATIVE_WORDSIZE == 64 +typedef unsigned long int PN_uint64; +#else +typedef unsigned long long int PN_uint64; +#endif + #endif typedef double PN_float64; typedef float PN_float32; -#endif // _LP64 #endif - - - diff --git a/dtool/src/parser-inc/Sources.pp b/dtool/src/parser-inc/Sources.pp index 736bc0185b..ce2f64e214 100644 --- a/dtool/src/parser-inc/Sources.pp +++ b/dtool/src/parser-inc/Sources.pp @@ -1,6 +1,6 @@ #define INSTALL_PARSER_INC \ algorithm deque ft2build.h hash_map hash_set iostream list map memory \ - pair pthread.h queue set stack stdcompare.h stdtypedefs.h \ + pair pthread.h queue set stack stdcompare.h stdtypedefs.h stdint.h \ string vector windows.h winsock2.h zlib.h files.h hex.h \ math.h md5.h evp.h bits/pthreadtypes.h \ openssl/md5.h openssl/evp.h openssl/rand.h openssl/ssl.h \ diff --git a/dtool/src/parser-inc/stdtypedefs.h b/dtool/src/parser-inc/stdtypedefs.h index b5b7287964..14db248dd5 100644 --- a/dtool/src/parser-inc/stdtypedefs.h +++ b/dtool/src/parser-inc/stdtypedefs.h @@ -38,15 +38,6 @@ typedef unsigned long ulong; typedef unsigned short ushort; typedef unsigned char uchar; -typedef unsigned char uint8_t; -typedef char int8_t; -typedef unsigned short uint16_t; -typedef short int16_t; -typedef unsigned int uint32_t; -typedef int int32_t; -typedef unsigned long long uint64_t; -typedef long long int64_t; - #define NULL ((void *)0) typedef int fd_set; diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index 0aec4e3acc..366d9e2ed6 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -1305,6 +1305,7 @@ DTOOL_CONFIG=[ ("PHAVE_DIRENT_H", 'UNDEF', '1'), ("PHAVE_SYS_SOUNDCARD_H", 'UNDEF', '1'), ("PHAVE_UCONTEXT_H", 'UNDEF', '1'), + ("PHAVE_STDINT_H", 'UNDEF', '1'), ("HAVE_RTTI", '1', '1'), ("HAVE_X11", 'UNDEF', '1'), ("HAVE_XRANDR", 'UNDEF', '1'),