X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fincludes%2FStgTypes.h;h=ae9eec5334559fb1aae579434f4bca9e8510c7fd;hb=5938a5f33a166374d9af7caa0638d65527e28d1c;hp=3470d7038dbdf2191e181467a43454ef2a006a96;hpb=21462c00b3241f15de3b145ac92ee5b266b5733a;p=ghc-hetmet.git diff --git a/ghc/includes/StgTypes.h b/ghc/includes/StgTypes.h index 3470d70..ae9eec5 100644 --- a/ghc/includes/StgTypes.h +++ b/ghc/includes/StgTypes.h @@ -1,23 +1,34 @@ /* ----------------------------------------------------------------------------- - * $Id: StgTypes.h,v 1.5 1999/03/02 19:44:21 sof Exp $ * - * (c) The GHC Team, 1998-1999 + * (c) The GHC Team, 1998-2004 + * + * Various C datatypes used in the run-time system. This is the + * lowest-level include file, after ghcconfig.h and RtsConfig.h. + * + * This module should define types *only*, all beginning with "Stg". * - * Various C datatypes used in the run-time system. - * Specifically: StgInt8, 16, 32, 64 StgWord8, 16, 32, 64 StgChar, StgFloat, StgDouble - ***** All the same size: ***** + ***** All the same size (i.e. sizeof(void *)): ***** StgPtr Basic pointer type StgWord Unit of heap allocation StgInt Signed version of StgWord StgAddr Generic address type + StgBool, StgVoid, StgClosurePtr, StgPtr, StgOffset, + StgTSOPtr, StgForeignPtr, StgStackOffset, StgStackPtr, + StgCode, StgArray, StgByteArray, StgStablePtr, StgFunPtr, + StgUnion. + * WARNING: Keep this file, MachDeps.h, and HsFFI.h in synch! + * + * NOTE: assumes #include "ghcconfig.h" + * + * Works with or without _POSIX_SOURCE. * * ---------------------------------------------------------------------------*/ @@ -27,6 +38,7 @@ /* * First, platform-dependent definitions of size-specific integers. * Assume for now that the int type is 32 bits. + * NOTE: Synch the following definitions with MachDeps.h! * ToDo: move these into a platform-dependent file. */ @@ -41,30 +53,28 @@ typedef unsigned short StgWord16; typedef signed int StgInt32; typedef unsigned int StgWord32; #else -#error GHC untested on this architecture: sizeof(unisgned int) != 4 -#endif - -/* This #define controls whether we need to support long longs on a particular - * platform. - * - * ToDo: find a proper home for (derived) configuration information like this. - */ -#if HAVE_LONG_LONG && SIZEOF_VOID_P < 8 -#define SUPPORT_LONG_LONGS +#error GHC untested on this architecture: sizeof(unsigned int) != 4 #endif #ifdef SUPPORT_LONG_LONGS /* assume long long is 64 bits */ -typedef unsigned long long int StgWord64; +# ifndef _MSC_VER typedef signed long long int StgInt64; +typedef unsigned long long int StgWord64; +# else +typedef __int64 StgInt64; +typedef unsigned __int64 StgWord64; +# endif #elif SIZEOF_LONG == 8 typedef signed long StgInt64; typedef unsigned long StgWord64; +#elif defined(__MSVC__) +typedef __int64 StgInt64; +typedef unsigned __int64 StgWord64; #else #error GHC untested on this architecture: sizeof(void *) < 8 and no long longs. #endif - /* * Define the standard word size we'll use on this machine: make it * big enough to hold a pointer. @@ -73,67 +83,52 @@ typedef unsigned long StgWord64; #if SIZEOF_VOID_P == 8 typedef StgInt64 StgInt; typedef StgWord64 StgWord; +typedef StgWord32 StgHalfWord; #else #if SIZEOF_VOID_P == 4 typedef StgInt32 StgInt; typedef StgWord32 StgWord; +typedef StgWord16 StgHalfWord; #else #error GHC untested on this architecture: sizeof(void *) != 4 or 8 #endif #endif +#define W_MASK (sizeof(W_)-1) + typedef void* StgAddr; /* * Other commonly-used STG datatypes. */ -typedef StgWord8 StgChar; - -/* - * If a double fits in an StgWord, don't bother using floats. - */ +typedef StgWord32 StgChar; +typedef int StgBool; -#if SIZEOF_DOUBLE == SIZEOF_VOID_P -typedef double StgFloat; -typedef double StgDouble; -#define FLOATS_AS_DOUBLES 1 -#else typedef float StgFloat; typedef double StgDouble; -#endif typedef void StgVoid; -typedef struct StgClosure_* StgClosurePtr; +typedef struct StgClosure_ StgClosure; +typedef StgClosure* StgClosurePtr; typedef StgWord* StgPtr; /* pointer into closure */ typedef StgWord StgOffset; /* byte offset within closure */ typedef struct StgTSO_* StgTSOPtr; -typedef void * StgForeignPtr; +typedef void* StgForeignPtr; typedef StgInt StgStackOffset; /* offset in words! */ typedef StgWord* StgStackPtr; typedef StgWord8 StgCode; /* close enough */ -typedef StgCode* StgCodePtr; typedef StgPtr* StgArray; /* the goods of an Array# */ typedef char* StgByteArray; /* the goods of a ByteArray# */ -typedef StgInt64 LI_; -typedef StgWord64 LW_; - -/* Stable Pointers: A stable pointer is represented as an index into - * the stable pointer table in the low 24 bits with a weight in the - * upper 8 bits. - */ -typedef StgWord StgStablePtr; - -#define STABLEPTR_WEIGHT_MASK (0xff << ((sizeof(StgWord)-1) * BITS_PER_BYTE)) -#define STABLEPTR_WEIGHT_SHIFT (BITS_IN(StgWord) - 8) +typedef void* StgStablePtr; /* Types for the generated C functions @@ -152,46 +147,4 @@ typedef StgWord StgStablePtr; typedef void *(*(*StgFunPtr)(void))(void); typedef StgFunPtr StgFun(void); -typedef union { - StgWord w; - StgAddr a; - StgChar c; - StgFloat f; - StgInt i; - StgPtr p; - StgClosurePtr cl; - StgStackOffset offset; /* unused? */ - StgByteArray b; - StgTSOPtr t; -} StgUnion; - -/* - * Shorthand forms - */ - -typedef StgChar C_; -typedef StgWord W_; -typedef StgWord* P_; -typedef P_* PP_; -typedef StgInt I_; -typedef StgAddr A_; -typedef const StgWord* D_; -typedef StgFunPtr F_; -typedef StgByteArray B_; -typedef StgClosurePtr L_; - -/* - * We often want to know the size of something in units of an - * StgWord... (rounded up, of course!) - */ - -#define sizeofW(t) ((sizeof(t)+sizeof(W_)-1)/sizeof(W_)) - -/* - * It's nice to be able to grep for casts - */ - -#define stgCast(ty,e) ((ty)(e)) - -#endif STGTYPES_H - +#endif /* STGTYPES_H */