Compact Regions
[ghc.git] / includes / MachDeps.h
1 /* -----------------------------------------------------------------------------
2 *
3 * (c) The University of Glasgow 2002
4 *
5 * Definitions that characterise machine specific properties of basic
6 * types (C & Haskell).
7 *
8 * NB: Keep in sync with HsFFI.h and StgTypes.h.
9 * NB: THIS FILE IS INCLUDED IN HASKELL SOURCE!
10 *
11 * To understand the structure of the RTS headers, see the wiki:
12 * http://ghc.haskell.org/trac/ghc/wiki/Commentary/SourceTree/Includes
13 *
14 * ---------------------------------------------------------------------------*/
15
16 #ifndef MACHDEPS_H
17 #define MACHDEPS_H
18
19 /* Sizes of C types come from here... */
20 #include "ghcautoconf.h"
21
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#
26 *
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.
29 */
30
31 #define SIZEOF_HSCHAR SIZEOF_WORD32
32 #define ALIGNMENT_HSCHAR ALIGNMENT_WORD32
33
34 #define SIZEOF_HSINT SIZEOF_VOID_P
35 #define ALIGNMENT_HSINT ALIGNMENT_VOID_P
36
37 #define SIZEOF_HSWORD SIZEOF_VOID_P
38 #define ALIGNMENT_HSWORD ALIGNMENT_VOID_P
39
40 #define SIZEOF_HSDOUBLE SIZEOF_DOUBLE
41 #define ALIGNMENT_HSDOUBLE ALIGNMENT_DOUBLE
42
43 #define SIZEOF_HSFLOAT SIZEOF_FLOAT
44 #define ALIGNMENT_HSFLOAT ALIGNMENT_FLOAT
45
46 #define SIZEOF_HSPTR SIZEOF_VOID_P
47 #define ALIGNMENT_HSPTR ALIGNMENT_VOID_P
48
49 #define SIZEOF_HSFUNPTR SIZEOF_VOID_P
50 #define ALIGNMENT_HSFUNPTR ALIGNMENT_VOID_P
51
52 #define SIZEOF_HSSTABLEPTR SIZEOF_VOID_P
53 #define ALIGNMENT_HSSTABLEPTR ALIGNMENT_VOID_P
54
55 #define SIZEOF_INT8 SIZEOF_INT8_T
56 #define ALIGNMENT_INT8 ALIGNMENT_INT8_T
57
58 #define SIZEOF_WORD8 SIZEOF_UINT8_T
59 #define ALIGNMENT_WORD8 ALIGNMENT_UINT8_T
60
61 #define SIZEOF_INT16 SIZEOF_INT16_T
62 #define ALIGNMENT_INT16 ALIGNMENT_INT16_T
63
64 #define SIZEOF_WORD16 SIZEOF_UINT16_T
65 #define ALIGNMENT_WORD16 ALIGNMENT_UINT16_T
66
67 #define SIZEOF_INT32 SIZEOF_INT32_T
68 #define ALIGNMENT_INT32 ALIGNMENT_INT32_T
69
70 #define SIZEOF_WORD32 SIZEOF_UINT32_T
71 #define ALIGNMENT_WORD32 ALIGNMENT_UINT32_T
72
73 #define SIZEOF_INT64 SIZEOF_INT64_T
74 #define ALIGNMENT_INT64 ALIGNMENT_INT64_T
75
76 #define SIZEOF_WORD64 SIZEOF_UINT64_T
77 #define ALIGNMENT_WORD64 ALIGNMENT_UINT64_T
78
79 #ifndef WORD_SIZE_IN_BITS
80 #if SIZEOF_HSWORD == 4
81 #define WORD_SIZE_IN_BITS 32
82 #define WORD_SIZE_IN_BITS_FLOAT 32.0
83 #else
84 #define WORD_SIZE_IN_BITS 64
85 #define WORD_SIZE_IN_BITS_FLOAT 64.0
86 #endif
87 #endif
88
89 #ifndef TAG_BITS
90 #if SIZEOF_HSWORD == 4
91 #define TAG_BITS 2
92 #else
93 #define TAG_BITS 3
94 #endif
95 #endif
96
97 #define TAG_MASK ((1 << TAG_BITS) - 1)
98
99 #endif /* MACHDEPS_H */