[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: 64Bit ints
Sam Lantinga wrote:
>> I experimented a bit with "long long" variables, and they apparently behave
>> just like a nice 64bit int should behave. Arithmetic operations work,
>Play on different systems, and different OS's. :)
Ok, Sorry for being so imprecise. That was mainly a sort of internal note
for the "knowing ones" ;)
So here's some more context:
In out main header file wa have some custom type declarations, including
these:
----8<--------8<-------
[...]
/***
Do 64 bit integers exist?
Thanks Yong Chi for the hack for detecting
64 bit architectures.
***/
#if INT_MAX < LONG_MAX
#define _PP_64BIT_ARCH
#define _PP_64BIT_INTS
#elif defined (__GNUC__)
#define _PP_64BIT_INTS
#endif
[...]
/***
Integers with guaranteed _minimum_ size.
These could be larger than you expect,
they are designed for speed.
***/
typedef long int ppInt32;
typedef long int ppInt16;
typedef long int ppInt8;
typedef unsigned long int ppuInt32;
typedef unsigned long int ppuInt16;
typedef unsigned long int ppuInt8;
/*64 bits ints might exist. Preferably becuase this is a 64
bit architecture, but we will use the GCC long long type if we
have to.
*/
#ifdef _PP_64BIT_INTS
#ifdef _PP_64BIT_ARCH
typedef long ppInt64;
typedef unsigned long ppuInt64;
#elif defined(__GNUC__)
typedef long long ppInt64;
typedef unsigned long long ppuInt64;
#endif
#endif
/***
Integers with guaranteed _exact_ size.
***/
typedef int pp32;
typedef short pp16;
typedef signed char pp8;
typedef unsigned int ppu32;
typedef unsigned short ppu16;
typedef unsigned char ppu8;
#ifdef _PP_64BIT_INTS
#ifdef _PP_64BIT_ARCH
typedef long pp64;
typedef unsigned long ppu64;
#elif __GNUC__
typedef long long pp64;
typedef unsigned long long ppu64;
#else
# define PP_NO_64BIT_INTEGERS
#endif
#endif
[...]
-------8<--------8<---------
I.e. long longs are used as 64bit ints only on non-native 64Bit systems
with gcc/g++
And *that* should be pretty safe ;)
But I'm always grateful for more tips on handling this.
Cu
Christian
--
Win98 - Now with DirectCrash [tm]