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_HSFOREIGNPTR SIZEOF_VOID_P
62 #define ALIGNMENT_HSFOREIGNPTR ALIGNMENT_VOID_P
64 #define SIZEOF_HSSTABLEPTR SIZEOF_VOID_P
65 #define ALIGNMENT_HSSTABLEPTR ALIGNMENT_VOID_P
67 #define SIZEOF_INT8 SIZEOF_CHAR
68 #define ALIGNMENT_INT8 ALIGNMENT_CHAR
70 #define SIZEOF_WORD8 SIZEOF_UNSIGNED_CHAR
71 #define ALIGNMENT_WORD8 ALIGNMENT_UNSIGNED_CHAR
73 #define SIZEOF_INT16 SIZEOF_SHORT
74 #define ALIGNMENT_INT16 ALIGNMENT_SHORT
76 #define SIZEOF_WORD16 SIZEOF_UNSIGNED_SHORT
77 #define ALIGNMENT_WORD16 ALIGNMENT_UNSIGNED_SHORT
79 #define SIZEOF_INT32 SIZEOF_INT
80 #define ALIGNMENT_INT32 ALIGNMENT_INT
82 #define SIZEOF_WORD32 SIZEOF_UNSIGNED_INT
83 #define ALIGNMENT_WORD32 ALIGNMENT_UNSIGNED_INT
85 #if HAVE_LONG_LONG && SIZEOF_VOID_P < 8
86 /* assume long long is 64 bits */
87 #define SIZEOF_INT64 SIZEOF_LONG_LONG
88 #define ALIGNMENT_INT64 ALIGNMENT_LONG_LONG
89 #define SIZEOF_WORD64 SIZEOF_UNSIGNED_LONG_LONG
90 #define ALIGNMENT_WORD64 ALIGNMENT_UNSIGNED_LONG_LONG
91 #elif SIZEOF_LONG == 8
92 #define SIZEOF_INT64 SIZEOF_LONG
93 #define ALIGNMENT_INT64 ALIGNMENT_LONG
94 #define SIZEOF_WORD64 SIZEOF_UNSIGNED_LONG
95 #define ALIGNMENT_WORD64 ALIGNMENT_UNSIGNED_LONG
97 #error GHC untested on this architecture: sizeof(void *) < 8 and no long longs.
100 #ifndef WORD_SIZE_IN_BITS
101 #if SIZEOF_HSWORD == 4
102 #define WORD_SIZE_IN_BITS 32
104 #define WORD_SIZE_IN_BITS 64
109 #if SIZEOF_HSWORD == 4
116 #define TAG_MASK ((1 << TAG_BITS) - 1)
118 #endif /* MACHDEPS_H */