1 /* -----------------------------------------------------------------------------
3 * (c) The University of Glasgow 2002
5 * Definitions that characterise machine specific properties of basic
8 * NB: Keep in sync with HsFFI.h and StgTypes.h.
9 * NB: THIS FILE IS INCLUDED IN HASKELL SOURCE!
11 * To understand the structure of the RTS headers, see the wiki:
12 * http://hackage.haskell.org/trac/ghc/wiki/Commentary/SourceTree/Includes
14 * ---------------------------------------------------------------------------*/
19 /* Sizes of C types come from here... */
20 #include "ghcautoconf.h"
22 /* Sizes of Haskell types follow. These sizes correspond to:
23 * - the number of bytes in the primitive type (eg. Int#)
24 * - the number of bytes in the external representation (eg. HsInt)
25 * - the scale offset used by writeFooOffAddr#
27 * In the heap, the type may take up more space: eg. SIZEOF_INT8 == 1,
28 * but it takes up SIZEOF_HSWORD (4 or 8) bytes in the heap.
31 /* First, check some assumptions.. */
33 #error GHC untested on this architecture: sizeof(char) != 1
37 #error GHC untested on this architecture: sizeof(short) != 2
40 #if SIZEOF_UNSIGNED_INT != 4
41 #error GHC untested on this architecture: sizeof(unsigned int) != 4
44 #define SIZEOF_HSCHAR SIZEOF_WORD32
45 #define ALIGNMENT_HSCHAR ALIGNMENT_WORD32
47 #define SIZEOF_HSINT SIZEOF_VOID_P
48 #define ALIGNMENT_HSINT ALIGNMENT_VOID_P
50 #define SIZEOF_HSWORD SIZEOF_VOID_P
51 #define ALIGNMENT_HSWORD ALIGNMENT_VOID_P
53 #define SIZEOF_HSDOUBLE SIZEOF_DOUBLE
54 #define ALIGNMENT_HSDOUBLE ALIGNMENT_DOUBLE
56 #define SIZEOF_HSFLOAT SIZEOF_FLOAT
57 #define ALIGNMENT_HSFLOAT ALIGNMENT_FLOAT
59 #define SIZEOF_HSPTR SIZEOF_VOID_P
60 #define ALIGNMENT_HSPTR ALIGNMENT_VOID_P
62 #define SIZEOF_HSFUNPTR SIZEOF_VOID_P
63 #define ALIGNMENT_HSFUNPTR ALIGNMENT_VOID_P
65 #define SIZEOF_HSSTABLEPTR SIZEOF_VOID_P
66 #define ALIGNMENT_HSSTABLEPTR ALIGNMENT_VOID_P
68 #define SIZEOF_INT8 SIZEOF_CHAR
69 #define ALIGNMENT_INT8 ALIGNMENT_CHAR
71 #define SIZEOF_WORD8 SIZEOF_UNSIGNED_CHAR
72 #define ALIGNMENT_WORD8 ALIGNMENT_UNSIGNED_CHAR
74 #define SIZEOF_INT16 SIZEOF_SHORT
75 #define ALIGNMENT_INT16 ALIGNMENT_SHORT
77 #define SIZEOF_WORD16 SIZEOF_UNSIGNED_SHORT
78 #define ALIGNMENT_WORD16 ALIGNMENT_UNSIGNED_SHORT
80 #define SIZEOF_INT32 SIZEOF_INT
81 #define ALIGNMENT_INT32 ALIGNMENT_INT
83 #define SIZEOF_WORD32 SIZEOF_UNSIGNED_INT
84 #define ALIGNMENT_WORD32 ALIGNMENT_UNSIGNED_INT
86 #if HAVE_LONG_LONG && SIZEOF_VOID_P < 8
87 /* assume long long is 64 bits */
88 #define SIZEOF_INT64 SIZEOF_LONG_LONG
89 #define ALIGNMENT_INT64 ALIGNMENT_LONG_LONG
90 #define SIZEOF_WORD64 SIZEOF_UNSIGNED_LONG_LONG
91 #define ALIGNMENT_WORD64 ALIGNMENT_UNSIGNED_LONG_LONG
92 #elif SIZEOF_LONG == 8
93 #define SIZEOF_INT64 SIZEOF_LONG
94 #define ALIGNMENT_INT64 ALIGNMENT_LONG
95 #define SIZEOF_WORD64 SIZEOF_UNSIGNED_LONG
96 #define ALIGNMENT_WORD64 ALIGNMENT_UNSIGNED_LONG
98 #error GHC untested on this architecture: sizeof(void *) < 8 and no long longs.
101 #ifndef WORD_SIZE_IN_BITS
102 #if SIZEOF_HSWORD == 4
103 #define WORD_SIZE_IN_BITS 32
105 #define WORD_SIZE_IN_BITS 64
110 #if SIZEOF_HSWORD == 4
117 #define TAG_MASK ((1 << TAG_BITS) - 1)
119 #endif /* MACHDEPS_H */