better 64-bit support

This commit is contained in:
David Rose 2007-04-05 15:33:53 +00:00
parent 291c14a9b4
commit 846e46b8c7
3 changed files with 41 additions and 1 deletions

View File

@ -265,6 +265,15 @@
#endif #endif
/* Try to determine if we're compiling in a 64-bit mode. */
#if defined(_LP64)
#define NATIVE_WORDSIZE 64
#else
#define NATIVE_WORDSIZE 32
#endif
/* /*
We define the macros BEGIN_PUBLISH and END_PUBLISH to bracket We define the macros BEGIN_PUBLISH and END_PUBLISH to bracket
functions and global variable definitions that are to be published functions and global variable definitions that are to be published

View File

@ -25,7 +25,24 @@
// the various numeric types for unsigned and signed numbers of // the various numeric types for unsigned and signed numbers of
// various widths. // various widths.
// For now, we'll just assume a typical 32-bit environment. #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 signed char PN_int8;
typedef short PN_int16; typedef short PN_int16;
@ -46,6 +63,7 @@ typedef unsigned long long PN_uint64;
typedef double PN_float64; typedef double PN_float64;
typedef float PN_float32; typedef float PN_float32;
#endif // _LP64
#endif #endif

View File

@ -21,6 +21,7 @@
#include "typeHandle.h" #include "typeHandle.h"
#include "typedObject.h" #include "typedObject.h"
#include "indent.h" #include "indent.h"
#include "numeric_types.h"
#include <algorithm> #include <algorithm>
@ -567,6 +568,18 @@ TypeRegistry() {
_handle_registry.push_back(NULL); _handle_registry.push_back(NULL);
_derivations_fresh = false; _derivations_fresh = false;
// Here's a few sanity checks on the sizes of our words. We have to
// put it here, at runtime, since there doesn't appear to be a
// cross-platform compile-time way to verify that we've chosen the
// right word sizes.
assert(sizeof(PN_uint8) == 1 && sizeof(PN_int8) == 1);
assert(sizeof(PN_uint16) == 2 && sizeof(PN_int16) == 2);
assert(sizeof(PN_uint32) == 4 && sizeof(PN_int32) == 4);
assert(sizeof(PN_uint64) == 8 && sizeof(PN_int64) == 8);
assert(sizeof(PN_float32) == 4);
assert(sizeof(PN_float64) == 8);
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////