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!
10 * ---------------------------------------------------------------------------*/
15 /* Sizes of C types come from here... */
16 #include "ghcautoconf.h"
18 /* Sizes of Haskell types follow. These sizes correspond to:
19 * - the number of bytes in the primitive type (eg. Int#)
20 * - the number of bytes in the external representation (eg. HsInt)
21 * - the scale offset used by writeFooOffAddr#
23 * In the heap, the type may take up more space: eg. SIZEOF_INT8 == 1,
24 * but it takes up SIZEOF_HSWORD (4 or 8) bytes in the heap.
27 /* First, check some assumptions.. */
29 #error GHC untested on this architecture: sizeof(char) != 1
33 #error GHC untested on this architecture: sizeof(short) != 2
36 #if SIZEOF_UNSIGNED_INT != 4
37 #error GHC untested on this architecture: sizeof(unsigned int) != 4
40 #define SIZEOF_HSCHAR SIZEOF_WORD32
41 #define ALIGNMENT_HSCHAR ALIGNMENT_WORD32
43 #define SIZEOF_HSINT SIZEOF_VOID_P
44 #define ALIGNMENT_HSINT ALIGNMENT_VOID_P
46 #define SIZEOF_HSWORD SIZEOF_VOID_P
47 #define ALIGNMENT_HSWORD ALIGNMENT_VOID_P
49 #define SIZEOF_HSDOUBLE SIZEOF_DOUBLE
50 #define ALIGNMENT_HSDOUBLE ALIGNMENT_DOUBLE
52 #define SIZEOF_HSFLOAT SIZEOF_FLOAT
53 #define ALIGNMENT_HSFLOAT ALIGNMENT_FLOAT
55 #define SIZEOF_HSPTR SIZEOF_VOID_P
56 #define ALIGNMENT_HSPTR ALIGNMENT_VOID_P
58 #define SIZEOF_HSFUNPTR SIZEOF_VOID_P
59 #define ALIGNMENT_HSFUNPTR ALIGNMENT_VOID_P
61 #define SIZEOF_HSSTABLEPTR SIZEOF_VOID_P
62 #define ALIGNMENT_HSSTABLEPTR ALIGNMENT_VOID_P
64 #define SIZEOF_INT8 SIZEOF_CHAR
65 #define ALIGNMENT_INT8 ALIGNMENT_CHAR
67 #define SIZEOF_WORD8 SIZEOF_UNSIGNED_CHAR
68 #define ALIGNMENT_WORD8 ALIGNMENT_UNSIGNED_CHAR
70 #define SIZEOF_INT16 SIZEOF_SHORT
71 #define ALIGNMENT_INT16 ALIGNMENT_SHORT
73 #define SIZEOF_WORD16 SIZEOF_UNSIGNED_SHORT
74 #define ALIGNMENT_WORD16 ALIGNMENT_UNSIGNED_SHORT
76 #define SIZEOF_INT32 SIZEOF_INT
77 #define ALIGNMENT_INT32 ALIGNMENT_INT
79 #define SIZEOF_WORD32 SIZEOF_UNSIGNED_INT
80 #define ALIGNMENT_WORD32 ALIGNMENT_UNSIGNED_INT
82 #if HAVE_LONG_LONG && SIZEOF_VOID_P < 8
83 /* assume long long is 64 bits */
84 #define SIZEOF_INT64 SIZEOF_LONG_LONG
85 #define ALIGNMENT_INT64 ALIGNMENT_LONG_LONG
86 #define SIZEOF_WORD64 SIZEOF_UNSIGNED_LONG_LONG
87 #define ALIGNMENT_WORD64 ALIGNMENT_UNSIGNED_LONG_LONG
88 #elif SIZEOF_LONG == 8
89 #define SIZEOF_INT64 SIZEOF_LONG
90 #define ALIGNMENT_INT64 ALIGNMENT_LONG
91 #define SIZEOF_WORD64 SIZEOF_UNSIGNED_LONG
92 #define ALIGNMENT_WORD64 ALIGNMENT_UNSIGNED_LONG
94 #error GHC untested on this architecture: sizeof(void *) < 8 and no long longs.
97 #ifndef WORD_SIZE_IN_BITS
98 #if SIZEOF_HSWORD == 4
99 #define WORD_SIZE_IN_BITS 32
101 #define WORD_SIZE_IN_BITS 64
106 #if SIZEOF_HSWORD == 4
113 #define TAG_MASK ((1 << TAG_BITS) - 1)
115 #endif /* MACHDEPS_H */