Keoncheol said:
I wonder how gcc treat 64bit integer type(long long int) internally in 32bit
machine.
The following comments apply to gcc 3.3.1, but the same or similar
structures likely exist in the latest version (3.3.3) as well.
You can see for yourself how gcc handles the "long long" type by
examining two files from the source distribution: gcc/libgcc2.h and
gcc/longlong.h.
The first file defines the following struct and union:
#if LIBGCC2_WORDS_BIG_ENDIAN
struct DWstruct {Wtype high, low;};
#else
struct DWstruct {Wtype low, high;};
#endif
typedef union
{
struct DWstruct s;
DWtype ll;
} DWunion;
The second file contains a flurry of assembler macros that define the
primitive "long long" operations for different processor types. The
"DWunion" type is employed to hold "long long" values for both 32-bit
and 64-bit processors.
As you can see (and as you might have well guessed), "long long" values
are manipulated as structs on 32-bit machines, with the "high" and "low"
members storing the upper and lower 32-bits, respectively, of the 64-bit
value.
NB: this description presents an over-simplified picture of relevant
header files for the purpose of providing a brief explanation. To
obtain of fuller and more precise understanding of what's going on with
gcc's handling of the "long long" type, a much more extensive review of
the source code would be required. In other words, things are not
always quite as simple as they look <g>
Mark