/* ----------------------------------------------------------------------------
- * $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
*
/* 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
/* -----------------------------------------------------------------------------
- * $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
*
typedef StgInt16 HsInt16;
typedef StgInt32 HsInt32;
typedef StgInt64 HsInt64;
+typedef StgWord HsWord;
typedef StgWord8 HsWord8;
typedef StgWord16 HsWord16;
typedef StgWord32 HsWord32;
/* ----------------------------------------------------------------------------
- * $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
*
#ifndef RTSAPI_H
#define RTSAPI_H
+#include "HsFFI.h"
+
/*
* Running the scheduler
*/
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.
------------------------------------------------------------------------- */
/* ----------------------------------------------------------------------------
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
/* -----------------------------------------------------------------------------
- * $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
/* -----------------------------------------------------------------------------
- * $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
*
#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"
/* -----------------------------------------------------------------------------
- * $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
#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.
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 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
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 */
/* ----------------------------------------------------------------------------
- * $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
*
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;
}
HaskellObj
-rts_mkInt (int i)
+rts_mkInt (HsInt i)
{
StgClosure *p = (StgClosure *)allocate(CONSTR_sizeW(0,1));
p->header.info = Izh_con_info;
}
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,
}
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,
}
HaskellObj
-rts_mkInt32 (int i)
+rts_mkInt32 (HsInt32 i)
{
StgClosure *p = (StgClosure *)allocate(CONSTR_sizeW(0,1));
/* see mk_Int8 comment */
}
HaskellObj
-rts_mkInt64 (HsInt64_ i)
+rts_mkInt64 (HsInt64 i)
{
long long *tmp;
StgClosure *p = (StgClosure *)allocate(CONSTR_sizeW(0,2));
}
HaskellObj
-rts_mkWord (unsigned int i)
+rts_mkWord (HsWord i)
{
StgClosure *p = (StgClosure *)allocate(CONSTR_sizeW(0,1));
p->header.info = Wzh_con_info;
}
HaskellObj
-rts_mkWord8 (unsigned int w)
+rts_mkWord8 (HsWord8 w)
{
/* see rts_mkInt* comments */
StgClosure *p = (StgClosure *)allocate(CONSTR_sizeW(0,1));
}
HaskellObj
-rts_mkWord16 (unsigned int w)
+rts_mkWord16 (HsWord16 w)
{
/* see rts_mkInt* comments */
StgClosure *p = (StgClosure *)allocate(CONSTR_sizeW(0,1));
}
HaskellObj
-rts_mkWord32 (unsigned int w)
+rts_mkWord32 (HsWord32 w)
{
/* see rts_mkInt* comments */
StgClosure *p = (StgClosure *)allocate(CONSTR_sizeW(0,1));
}
HaskellObj
-rts_mkWord64 (HsWord64_ w)
+rts_mkWord64 (HsWord64 w)
{
unsigned long long *tmp;
}
HaskellObj
-rts_mkFloat (float f)
+rts_mkFloat (HsFloat f)
{
StgClosure *p = (StgClosure *)allocate(CONSTR_sizeW(0,1));
p->header.info = Fzh_con_info;
}
HaskellObj
-rts_mkDouble (double d)
+rts_mkDouble (HsDouble d)
{
StgClosure *p = (StgClosure *)allocate(CONSTR_sizeW(0,sizeofW(StgDouble)));
p->header.info = Dzh_con_info;
}
HaskellObj
-rts_mkStablePtr (StgStablePtr s)
+rts_mkStablePtr (HsStablePtr s)
{
StgClosure *p = (StgClosure *)allocate(sizeofW(StgHeader)+1);
p->header.info = StablePtr_con_info;
}
HaskellObj
-rts_mkAddr (void *a)
+rts_mkAddr (HsAddr a)
{
StgClosure *p = (StgClosure *)allocate(sizeofW(StgHeader)+1);
p->header.info = Azh_con_info;
#ifdef COMPILER /* GHC has em, Hugs doesn't */
HaskellObj
-rts_mkBool (StgBool b)
+rts_mkBool (HsBool b)
{
if (b) {
return (StgClosure *)True_closure;
Deconstructing Haskell objects
------------------------------------------------------------------------- */
-unsigned int
+HsChar
rts_getChar (HaskellObj p)
{
if ( p->header.info == Czh_con_info ||
}
}
-int
+HsInt
rts_getInt (HaskellObj p)
{
if ( 1 ||
}
}
-int
+HsInt32
rts_getInt32 (HaskellObj p)
{
if ( 1 ||
}
}
-unsigned int
+HsWord
rts_getWord (HaskellObj p)
{
if ( 1 || /* see above comment */
}
}
-unsigned int
+HsWord32
rts_getWord32 (HaskellObj p)
{
if ( 1 || /* see above comment */
}
}
-float
+HsFloat
rts_getFloat (HaskellObj p)
{
if ( p->header.info == Fzh_con_info ||
}
}
-double
+HsDouble
rts_getDouble (HaskellObj p)
{
if ( p->header.info == Dzh_con_info ||
}
}
-StgStablePtr
+HsStablePtr
rts_getStablePtr (HaskellObj p)
{
if ( p->header.info == StablePtr_con_info ||
}
}
-void *
+HsAddr
rts_getAddr (HaskellObj p)
{
if ( p->header.info == Azh_con_info ||
}
#ifdef COMPILER /* GHC has em, Hugs doesn't */
-int
+HsBool
rts_getBool (HaskellObj p)
{
if (p == True_closure) {