1 /* -----------------------------------------------------------------------------
3 * (c) The GHC Team, 1998-2004
5 * Various C datatypes used in the run-time system. This is the
6 * lowest-level include file, after ghcconfig.h and RtsConfig.h.
8 * Do not #include this file directly: #include "Rts.h" instead.
10 * To understand the structure of the RTS headers, see the wiki:
11 * http://hackage.haskell.org/trac/ghc/wiki/Commentary/SourceTree/Includes
13 * NOTE: assumes #include "ghcconfig.h"
15 * Works with or without _POSIX_SOURCE.
17 * WARNING: Keep this file, MachDeps.h, and HsFFI.h in synch!
19 * ---------------------------------------------------------------------------*/
25 * This module should define types *only*, all beginning with "Stg".
31 StgChar, StgFloat, StgDouble
33 ***** All the same size (i.e. sizeof(void *)): *****
34 StgPtr Basic pointer type
35 StgWord Unit of heap allocation
36 StgInt Signed version of StgWord
37 StgAddr Generic address type
39 StgBool, StgVoid, StgPtr, StgOffset,
40 StgCode, StgStablePtr, StgFunPtr,
45 * First, platform-dependent definitions of size-specific integers.
46 * Assume for now that the int type is 32 bits.
47 * NOTE: Synch the following definitions with MachDeps.h!
48 * ToDo: move these into a platform-dependent file.
51 typedef signed char StgInt8;
52 typedef unsigned char StgWord8;
54 typedef signed short StgInt16;
55 typedef unsigned short StgWord16;
58 typedef signed long StgInt32;
59 typedef unsigned long StgWord32;
61 typedef signed int StgInt32;
62 typedef unsigned int StgWord32;
64 #error GHC untested on this architecture: sizeof(int) != 4
68 typedef signed long StgInt64;
69 typedef unsigned long StgWord64;
70 #elif defined(__MSVC__)
71 typedef __int64 StgInt64;
72 typedef unsigned __int64 StgWord64;
73 #elif SIZEOF_LONG_LONG == 8
74 typedef signed long long int StgInt64;
75 typedef unsigned long long int StgWord64;
77 #error cannot find a way to define StgInt64
81 * Define the standard word size we'll use on this machine: make it
82 * big enough to hold a pointer.
84 * It's useful if StgInt/StgWord are always the same as long, so that
85 * we can use a consistent printf format specifier without warnings on
86 * any platform. Fortunately this works at the moement; if it breaks
87 * in the future we'll have to start using macros for format
88 * specifiers (c.f. FMT_StgWord64 in Rts.h).
91 #if SIZEOF_VOID_P == 8
92 typedef StgInt64 StgInt;
93 typedef StgWord64 StgWord;
94 typedef StgInt32 StgHalfInt;
95 typedef StgWord32 StgHalfWord;
97 #if SIZEOF_VOID_P == 4
98 typedef StgInt32 StgInt;
99 typedef StgWord32 StgWord;
100 typedef StgInt16 StgHalfInt;
101 typedef StgWord16 StgHalfWord;
103 #error GHC untested on this architecture: sizeof(void *) != 4 or 8
107 #define W_MASK (sizeof(W_)-1)
110 * Other commonly-used STG datatypes.
113 typedef void* StgAddr;
114 typedef StgWord32 StgChar;
116 typedef float StgFloat;
117 typedef double StgDouble;
118 typedef StgWord* StgPtr; /* heap or stack pointer */
119 typedef StgWord volatile* StgVolatilePtr; /* pointer to volatile word */
120 typedef StgWord StgOffset; /* byte offset within closure */
121 typedef StgWord8 StgCode; /* close enough */
122 typedef void* StgStablePtr;
123 typedef StgWord8* StgByteArray;
126 Types for the generated C functions
128 return a pointer to the next function to be called
129 use: Ptr to Fun that returns a Ptr to Fun which returns Ptr to void
131 Note: Neither StgFunPtr not StgFun is quite right (that is,
132 StgFunPtr != StgFun*). So, the functions we define all have type
133 StgFun but we always have to cast them to StgFunPtr when we assign
135 The only way round this would be to write a recursive type but
136 C only allows that if you're defining a struct or union.
139 typedef void *(*(*StgFunPtr)(void))(void);
140 typedef StgFunPtr StgFun(void);
142 #endif /* STGTYPES_H */