Massive patch for the first months work adding System FC to GHC #35
[ghc-hetmet.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
12 #ifndef MACHDEPS_H
13 #define MACHDEPS_H
14
15 /* Sizes of C types come from here... */
16 #include "ghcautoconf.h"
17
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#
22  *
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.
25  */
26
27 /* First, check some assumptions.. */
28 #if SIZEOF_CHAR != 1
29 #error GHC untested on this architecture: sizeof(char) != 1
30 #endif
31
32 #if SIZEOF_SHORT != 2
33 #error GHC untested on this architecture: sizeof(short) != 2
34 #endif
35
36 #if SIZEOF_UNSIGNED_INT != 4
37 #error GHC untested on this architecture: sizeof(unsigned int) != 4
38 #endif
39
40 #define SIZEOF_HSCHAR           SIZEOF_WORD32
41 #define ALIGNMENT_HSCHAR        ALIGNMENT_WORD32
42
43 #define SIZEOF_HSINT            SIZEOF_VOID_P
44 #define ALIGNMENT_HSINT         ALIGNMENT_VOID_P
45
46 #define SIZEOF_HSWORD           SIZEOF_VOID_P
47 #define ALIGNMENT_HSWORD        ALIGNMENT_VOID_P
48
49 #define SIZEOF_HSDOUBLE         SIZEOF_DOUBLE
50 #define ALIGNMENT_HSDOUBLE      ALIGNMENT_DOUBLE
51
52 #define SIZEOF_HSFLOAT          SIZEOF_FLOAT
53 #define ALIGNMENT_HSFLOAT       ALIGNMENT_FLOAT
54
55 #define SIZEOF_HSPTR            SIZEOF_VOID_P
56 #define ALIGNMENT_HSPTR         ALIGNMENT_VOID_P
57
58 #define SIZEOF_HSFUNPTR         SIZEOF_VOID_P
59 #define ALIGNMENT_HSFUNPTR      ALIGNMENT_VOID_P
60
61 #define SIZEOF_HSFOREIGNPTR     SIZEOF_VOID_P
62 #define ALIGNMENT_HSFOREIGNPTR  ALIGNMENT_VOID_P
63
64 #define SIZEOF_HSSTABLEPTR      SIZEOF_VOID_P
65 #define ALIGNMENT_HSSTABLEPTR   ALIGNMENT_VOID_P
66
67 #define SIZEOF_INT8             SIZEOF_CHAR
68 #define ALIGNMENT_INT8          ALIGNMENT_CHAR
69
70 #define SIZEOF_WORD8            SIZEOF_UNSIGNED_CHAR
71 #define ALIGNMENT_WORD8         ALIGNMENT_UNSIGNED_CHAR
72
73 #define SIZEOF_INT16            SIZEOF_SHORT
74 #define ALIGNMENT_INT16         ALIGNMENT_SHORT
75
76 #define SIZEOF_WORD16           SIZEOF_UNSIGNED_SHORT
77 #define ALIGNMENT_WORD16        ALIGNMENT_UNSIGNED_SHORT
78
79 #define SIZEOF_INT32            SIZEOF_INT
80 #define ALIGNMENT_INT32         ALIGNMENT_INT
81
82 #define SIZEOF_WORD32           SIZEOF_UNSIGNED_INT
83 #define ALIGNMENT_WORD32        ALIGNMENT_UNSIGNED_INT
84
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
96 #else
97 #error GHC untested on this architecture: sizeof(void *) < 8 and no long longs.
98 #endif
99
100 #ifndef WORD_SIZE_IN_BITS
101 #if SIZEOF_HSWORD == 4
102 #define WORD_SIZE_IN_BITS       32
103 #else 
104 #define WORD_SIZE_IN_BITS       64
105 #endif
106 #endif
107
108 #endif /* MACHDEPS_H */