[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 64Bit ints



Matt Slot wrote:

>If you want to stay portable, you probably should make a suite of macros that
>take advantage intrinsic 64-bit types/arithmetic if available, and calculate
>them manually if not:
>
>   typedef unsigned short    UInt16;
>   typedef unsigned long     UInt32;
>
>#ifdef INTRINSIC_64BIT /* or something */
>
>   typedef unsigned longlong UInt64;
>   #define Add64(r,x,y)  (void) ((r) = (x) + (y))
>
>#else
>
>   typedef struct { UInt32 hi, lo; } UInt64;
>   #define Add64(r,x,y) __MyAdd64(&(r), &(x), &(y))
>
>#endif

That brings me to some other idea (not the one you aimed at though ;)
Currently 64bit ints are only used by PenguinFile's PakFile part
(in-PakFile offsets, file sizes), i.e. using 64bit ints makes only sense on
a native 64bit system (i.e. when stdio can handle 64bit sizes/offsets).
That means we have to do a bit more checking... especially in the PakFile
writing / mounting / file opening code if the read value actually fits in a
native long (the datatype used for fseek () & co).
Added to my TODO. Thx for the reminder.

Cu
	Christian
--

Troi, report to my room. Clothing optional