diff --git a/ghc/includes/Closures.h b/ghc/includes/Closures.h index ae3eadd20d78799b7e990c2d7560fbcd57ffd372..77d0725bf64076f22656ad8abed2898a9ce1992b 100644 --- a/ghc/includes/Closures.h +++ b/ghc/includes/Closures.h @@ -1,5 +1,5 @@ /* ---------------------------------------------------------------------------- - * $Id: Closures.h,v 1.18 2000/08/15 11:48:06 simonmar Exp $ + * $Id: Closures.h,v 1.19 2000/11/07 17:05:47 simonmar Exp $ * * (c) The GHC Team, 1998-1999 * @@ -137,10 +137,10 @@ typedef struct { /* All closures follow the generic format */ -typedef struct StgClosure_ { +struct StgClosure_ { StgHeader header; struct StgClosure_ *payload[0]; -} StgClosure; +}; /* What a stroke of luck - all our mutable closures follow the same * basic layout, with the mutable link field as the second field after diff --git a/ghc/includes/HsFFI.h b/ghc/includes/HsFFI.h index ca186a2aa1fea11a5704fe58046e3045af34200a..597cdef1464f231bc34b2b2bb4e8c7ec124722cc 100644 --- a/ghc/includes/HsFFI.h +++ b/ghc/includes/HsFFI.h @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * $Id: HsFFI.h,v 1.7 2000/11/07 13:30:40 simonmar Exp $ + * $Id: HsFFI.h,v 1.8 2000/11/07 17:05:47 simonmar Exp $ * * (c) The GHC Team, 2000 * @@ -65,6 +65,7 @@ typedef StgInt8 HsInt8; typedef StgInt16 HsInt16; typedef StgInt32 HsInt32; typedef StgInt64 HsInt64; +typedef StgWord HsWord; typedef StgWord8 HsWord8; typedef StgWord16 HsWord16; typedef StgWord32 HsWord32; diff --git a/ghc/includes/RtsAPI.h b/ghc/includes/RtsAPI.h index 348e57a510f903326ed69dd45bfe250edb9e653f..a78aa7a8cc74fb3b4742a8703d6db64237082541 100644 --- a/ghc/includes/RtsAPI.h +++ b/ghc/includes/RtsAPI.h @@ -1,5 +1,5 @@ /* ---------------------------------------------------------------------------- - * $Id: RtsAPI.h,v 1.17 2000/08/29 13:34:21 qrczak Exp $ + * $Id: RtsAPI.h,v 1.18 2000/11/07 17:05:47 simonmar Exp $ * * (c) The GHC Team, 1998-1999 * @@ -10,6 +10,8 @@ #ifndef RTSAPI_H #define RTSAPI_H +#include "HsFFI.h" + /* * Running the scheduler */ @@ -23,21 +25,6 @@ typedef enum { typedef StgClosure *HaskellObj; - -/* Make this compilable with Visual C++. We can't just use StgInt64 here, - * because this file should be compilable without reference to the rest - * of the RTS machinery. These are absolutely non-standard types, but - * I don't know what alternatives are safe if we don't #include anything - * here. - */ -#if defined(__MSVC__) -typedef __int64 HsInt64_; -typedef unsigned __int64 HsWord64_; -#else -typedef long long HsInt64_; -typedef unsigned long long HsWord64_; -#endif - /* ---------------------------------------------------------------------------- Starting up and shutting down the Haskell RTS. ------------------------------------------------------------------------- */ @@ -50,39 +37,39 @@ extern void getProgArgv ( int *argc, char **argv[] ); /* ---------------------------------------------------------------------------- Building Haskell objects from C datatypes. ------------------------------------------------------------------------- */ -HaskellObj rts_mkChar ( unsigned int c ); -HaskellObj rts_mkInt ( int i ); -HaskellObj rts_mkInt8 ( int i ); -HaskellObj rts_mkInt16 ( int i ); -HaskellObj rts_mkInt32 ( int i ); -HaskellObj rts_mkWord ( unsigned int w ); -HaskellObj rts_mkWord8 ( unsigned int w ); -HaskellObj rts_mkWord16 ( unsigned int w ); -HaskellObj rts_mkWord32 ( unsigned int w ); -HaskellObj rts_mkInt64 ( HsInt64_ i ); -HaskellObj rts_mkWord64 ( HsWord64_ w ); -HaskellObj rts_mkFloat ( float f ); -HaskellObj rts_mkDouble ( double f ); -HaskellObj rts_mkStablePtr ( StgStablePtr s ); -HaskellObj rts_mkAddr ( void *a ); -HaskellObj rts_mkBool ( int b ); -HaskellObj rts_mkString ( char *s ); +HaskellObj rts_mkChar ( HsChar c ); +HaskellObj rts_mkInt ( HsInt i ); +HaskellObj rts_mkInt8 ( HsInt8 i ); +HaskellObj rts_mkInt16 ( HsInt16 i ); +HaskellObj rts_mkInt32 ( HsInt32 i ); +HaskellObj rts_mkInt64 ( HsInt64 i ); +HaskellObj rts_mkWord ( HsWord w ); +HaskellObj rts_mkWord8 ( HsWord8 w ); +HaskellObj rts_mkWord16 ( HsWord16 w ); +HaskellObj rts_mkWord32 ( HsWord32 w ); +HaskellObj rts_mkWord64 ( HsWord64 w ); +HaskellObj rts_mkFloat ( HsFloat f ); +HaskellObj rts_mkDouble ( HsDouble f ); +HaskellObj rts_mkStablePtr ( HsStablePtr s ); +HaskellObj rts_mkAddr ( HsAddr a ); +HaskellObj rts_mkBool ( HsBool b ); +HaskellObj rts_mkString ( char *s ); HaskellObj rts_apply ( HaskellObj, HaskellObj ); /* ---------------------------------------------------------------------------- Deconstructing Haskell objects ------------------------------------------------------------------------- */ -unsigned int rts_getChar ( HaskellObj ); -int rts_getInt ( HaskellObj ); -int rts_getInt32 ( HaskellObj ); -unsigned int rts_getWord ( HaskellObj ); -unsigned int rts_getWord32 ( HaskellObj ); -float rts_getFloat ( HaskellObj ); -double rts_getDouble ( HaskellObj ); -StgStablePtr rts_getStablePtr ( HaskellObj ); -void * rts_getAddr ( HaskellObj ); -int rts_getBool ( HaskellObj ); +HsChar rts_getChar ( HaskellObj ); +HsInt rts_getInt ( HaskellObj ); +HsInt32 rts_getInt32 ( HaskellObj ); +HsWord rts_getWord ( HaskellObj ); +HsWord32 rts_getWord32 ( HaskellObj ); +HsFloat rts_getFloat ( HaskellObj ); +HsDouble rts_getDouble ( HaskellObj ); +HsStablePtr rts_getStablePtr ( HaskellObj ); +HsAddr rts_getAddr ( HaskellObj ); +HsBool rts_getBool ( HaskellObj ); /* ---------------------------------------------------------------------------- Evaluating Haskell expressions diff --git a/ghc/includes/Stable.h b/ghc/includes/Stable.h index d3dfb589a04f01a8286b64f1ea63a56bf34e6c26..66486bd6380b32779dd9345ece1b57fb39dee9ca 100644 --- a/ghc/includes/Stable.h +++ b/ghc/includes/Stable.h @@ -1,11 +1,21 @@ /* ----------------------------------------------------------------------------- - * $Id: Stable.h,v 1.6 2000/09/04 15:09:49 simonmar Exp $ + * $Id: Stable.h,v 1.7 2000/11/07 17:05:47 simonmar Exp $ * - * (c) The GHC Team, 1998-1999 + * (c) The GHC Team, 1998-2000 * - * Stable names and stable pointers + * Stable Pointers: A stable pointer is represented as an index into + * the stable pointer table in the low BITS_PER_WORD-8 bits with a + * weight in the upper 8 bits. * - * ---------------------------------------------------------------------------*/ + * SUP: StgStablePtr used to be a synonym for StgWord, but stable pointers + * are guaranteed to be void* on the C-side, so we have to do some occasional + * casting. Size is not a matter, because StgWord is always the same size as + * a void*. + * + * ----------------------------------------------------------------------------*/ + +#define STABLEPTR_WEIGHT_MASK ((StgWord)0xff << ((sizeof(StgWord)-1) * BITS_PER_BYTE)) +#define STABLEPTR_WEIGHT_SHIFT (BITS_IN(StgWord) - 8) /* ----------------------------------------------------------------------------- External C Interface diff --git a/ghc/includes/Stg.h b/ghc/includes/Stg.h index 6e5c1b1c4abd0796054ff1149f2e4ea62e0b69f4..fca8f31b90ce24c08e3f7c42ba16c8154e57ae3d 100644 --- a/ghc/includes/Stg.h +++ b/ghc/includes/Stg.h @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * $Id: Stg.h,v 1.32 2000/05/27 14:28:06 panne Exp $ + * $Id: Stg.h,v 1.33 2000/11/07 17:05:47 simonmar Exp $ * * (c) The GHC Team, 1998-1999 * @@ -102,13 +102,47 @@ void _stgAssert (char *, unsigned int); #endif /* DEBUG */ /* ----------------------------------------------------------------------------- - Include everything STG-ish + Global type definitions -------------------------------------------------------------------------- */ -/* Global type definitions*/ #include "StgTypes.h" #include "RtsTypes.h" +/* ----------------------------------------------------------------------------- + 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_; + +typedef StgInt64 LI_; +typedef StgWord64 LW_; + +/* + * 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)) + +/* ----------------------------------------------------------------------------- + Include everything STG-ish + -------------------------------------------------------------------------- */ + /* Global constaints */ #include "Constants.h" diff --git a/ghc/includes/StgTypes.h b/ghc/includes/StgTypes.h index 6e5f47da8fa36a86603f6bda913898de93c9aa3d..6ceb80cb41b9cf4843a9e8e2a559766ec499e176 100644 --- a/ghc/includes/StgTypes.h +++ b/ghc/includes/StgTypes.h @@ -1,24 +1,36 @@ /* ----------------------------------------------------------------------------- - * $Id: StgTypes.h,v 1.14 2000/11/07 13:30:40 simonmar Exp $ + * $Id: StgTypes.h,v 1.15 2000/11/07 17:05:47 simonmar Exp $ * * (c) The GHC Team, 1998-2000 * - * Various C datatypes used in the run-time system. - + * Various C datatypes used in the run-time system. This is the + * lowest-level include file (after config.h). + * + * This module should define types *only*, all beginning with "Stg". + * * 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 and HsFFI.h in synch! * + * NOTE: assumes #include "config.h" + * + * Works with or without _POSIX_SOURCE. + * * ---------------------------------------------------------------------------*/ #ifndef STGTYPES_H @@ -56,16 +68,18 @@ typedef unsigned int StgWord32; #ifdef SUPPORT_LONG_LONGS /* assume long long is 64 bits */ -typedef unsigned long long int StgWord64; typedef signed long long int StgInt64; +typedef unsigned long long int StgWord64; #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. @@ -97,7 +111,8 @@ typedef double StgDouble; 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 */ @@ -110,27 +125,12 @@ 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. - * SUP: StgStablePtr used to be a synonym for StgWord, but stable pointers - * are guaranteed to be void* on the C-side, so we have to do some occasional - * casting. Size is not a matter, because StgWord is always the same size as - * a void*. - */ typedef void* StgStablePtr; -#define STABLEPTR_WEIGHT_MASK ((StgWord)0xff << ((sizeof(StgWord)-1) * BITS_PER_BYTE)) -#define STABLEPTR_WEIGHT_SHIFT (BITS_IN(StgWord) - 8) - /* Types for the generated C functions take no arguments @@ -162,32 +162,4 @@ typedef union { 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 */ diff --git a/ghc/rts/RtsAPI.c b/ghc/rts/RtsAPI.c index de6de6268129174b561e1c229779243f32371bc8..4dc80ca46b16eeedcaa53fec62d564883a7abb5c 100644 --- a/ghc/rts/RtsAPI.c +++ b/ghc/rts/RtsAPI.c @@ -1,5 +1,5 @@ /* ---------------------------------------------------------------------------- - * $Id: RtsAPI.c,v 1.20 2000/08/29 13:34:21 qrczak Exp $ + * $Id: RtsAPI.c,v 1.21 2000/11/07 17:05:47 simonmar Exp $ * * (c) The GHC Team, 1998-2000 * @@ -19,7 +19,7 @@ Building Haskell objects from C datatypes. ------------------------------------------------------------------------- */ HaskellObj -rts_mkChar (unsigned int c) +rts_mkChar (HsChar c) { StgClosure *p = (StgClosure *)allocate(CONSTR_sizeW(0,1)); p->header.info = Czh_con_info; @@ -28,7 +28,7 @@ rts_mkChar (unsigned int c) } HaskellObj -rts_mkInt (int i) +rts_mkInt (HsInt i) { StgClosure *p = (StgClosure *)allocate(CONSTR_sizeW(0,1)); p->header.info = Izh_con_info; @@ -37,7 +37,7 @@ rts_mkInt (int i) } HaskellObj -rts_mkInt8 (int i) +rts_mkInt8 (HsInt8 i) { StgClosure *p = (StgClosure *)allocate(CONSTR_sizeW(0,1)); /* This is a 'cheat', using the static info table for Ints, @@ -51,7 +51,7 @@ rts_mkInt8 (int i) } HaskellObj -rts_mkInt16 (int i) +rts_mkInt16 (HsInt16 i) { StgClosure *p = (StgClosure *)allocate(CONSTR_sizeW(0,1)); /* This is a 'cheat', using the static info table for Ints, @@ -65,7 +65,7 @@ rts_mkInt16 (int i) } HaskellObj -rts_mkInt32 (int i) +rts_mkInt32 (HsInt32 i) { StgClosure *p = (StgClosure *)allocate(CONSTR_sizeW(0,1)); /* see mk_Int8 comment */ @@ -75,7 +75,7 @@ rts_mkInt32 (int i) } HaskellObj -rts_mkInt64 (HsInt64_ i) +rts_mkInt64 (HsInt64 i) { long long *tmp; StgClosure *p = (StgClosure *)allocate(CONSTR_sizeW(0,2)); @@ -87,7 +87,7 @@ rts_mkInt64 (HsInt64_ i) } HaskellObj -rts_mkWord (unsigned int i) +rts_mkWord (HsWord i) { StgClosure *p = (StgClosure *)allocate(CONSTR_sizeW(0,1)); p->header.info = Wzh_con_info; @@ -96,7 +96,7 @@ rts_mkWord (unsigned int i) } HaskellObj -rts_mkWord8 (unsigned int w) +rts_mkWord8 (HsWord8 w) { /* see rts_mkInt* comments */ StgClosure *p = (StgClosure *)allocate(CONSTR_sizeW(0,1)); @@ -106,7 +106,7 @@ rts_mkWord8 (unsigned int w) } HaskellObj -rts_mkWord16 (unsigned int w) +rts_mkWord16 (HsWord16 w) { /* see rts_mkInt* comments */ StgClosure *p = (StgClosure *)allocate(CONSTR_sizeW(0,1)); @@ -116,7 +116,7 @@ rts_mkWord16 (unsigned int w) } HaskellObj -rts_mkWord32 (unsigned int w) +rts_mkWord32 (HsWord32 w) { /* see rts_mkInt* comments */ StgClosure *p = (StgClosure *)allocate(CONSTR_sizeW(0,1)); @@ -126,7 +126,7 @@ rts_mkWord32 (unsigned int w) } HaskellObj -rts_mkWord64 (HsWord64_ w) +rts_mkWord64 (HsWord64 w) { unsigned long long *tmp; @@ -139,7 +139,7 @@ rts_mkWord64 (HsWord64_ w) } HaskellObj -rts_mkFloat (float f) +rts_mkFloat (HsFloat f) { StgClosure *p = (StgClosure *)allocate(CONSTR_sizeW(0,1)); p->header.info = Fzh_con_info; @@ -148,7 +148,7 @@ rts_mkFloat (float f) } HaskellObj -rts_mkDouble (double d) +rts_mkDouble (HsDouble d) { StgClosure *p = (StgClosure *)allocate(CONSTR_sizeW(0,sizeofW(StgDouble))); p->header.info = Dzh_con_info; @@ -157,7 +157,7 @@ rts_mkDouble (double d) } HaskellObj -rts_mkStablePtr (StgStablePtr s) +rts_mkStablePtr (HsStablePtr s) { StgClosure *p = (StgClosure *)allocate(sizeofW(StgHeader)+1); p->header.info = StablePtr_con_info; @@ -166,7 +166,7 @@ rts_mkStablePtr (StgStablePtr s) } HaskellObj -rts_mkAddr (void *a) +rts_mkAddr (HsAddr a) { StgClosure *p = (StgClosure *)allocate(sizeofW(StgHeader)+1); p->header.info = Azh_con_info; @@ -176,7 +176,7 @@ rts_mkAddr (void *a) #ifdef COMPILER /* GHC has em, Hugs doesn't */ HaskellObj -rts_mkBool (StgBool b) +rts_mkBool (HsBool b) { if (b) { return (StgClosure *)True_closure; @@ -207,7 +207,7 @@ rts_apply (HaskellObj f, HaskellObj arg) Deconstructing Haskell objects ------------------------------------------------------------------------- */ -unsigned int +HsChar rts_getChar (HaskellObj p) { if ( p->header.info == Czh_con_info || @@ -218,7 +218,7 @@ rts_getChar (HaskellObj p) } } -int +HsInt rts_getInt (HaskellObj p) { if ( 1 || @@ -230,7 +230,7 @@ rts_getInt (HaskellObj p) } } -int +HsInt32 rts_getInt32 (HaskellObj p) { if ( 1 || @@ -242,7 +242,7 @@ rts_getInt32 (HaskellObj p) } } -unsigned int +HsWord rts_getWord (HaskellObj p) { if ( 1 || /* see above comment */ @@ -254,7 +254,7 @@ rts_getWord (HaskellObj p) } } -unsigned int +HsWord32 rts_getWord32 (HaskellObj p) { if ( 1 || /* see above comment */ @@ -266,7 +266,7 @@ rts_getWord32 (HaskellObj p) } } -float +HsFloat rts_getFloat (HaskellObj p) { if ( p->header.info == Fzh_con_info || @@ -277,7 +277,7 @@ rts_getFloat (HaskellObj p) } } -double +HsDouble rts_getDouble (HaskellObj p) { if ( p->header.info == Dzh_con_info || @@ -288,7 +288,7 @@ rts_getDouble (HaskellObj p) } } -StgStablePtr +HsStablePtr rts_getStablePtr (HaskellObj p) { if ( p->header.info == StablePtr_con_info || @@ -299,7 +299,7 @@ rts_getStablePtr (HaskellObj p) } } -void * +HsAddr rts_getAddr (HaskellObj p) { if ( p->header.info == Azh_con_info || @@ -312,7 +312,7 @@ rts_getAddr (HaskellObj p) } #ifdef COMPILER /* GHC has em, Hugs doesn't */ -int +HsBool rts_getBool (HaskellObj p) { if (p == True_closure) {