1 /* -----------------------------------------------------------------------------
2 * $Id: MachDeps.h,v 1.8 2002/12/11 15:36:37 simonmar Exp $
4 * (c) The University of Glasgow 2002
6 * Definitions that characterise machine specific properties of basic
9 * NB: Keep in sync with HsFFI.h and StgTypes.h.
10 * NB: THIS FILE IS INCLUDED IN HASKELL SOURCE!
11 * ---------------------------------------------------------------------------*/
16 /* Sizes of C types come from here... */
19 /* Sizes of Haskell types follow. These sizes correspond to:
20 * - the number of bytes in the primitive type (eg. Int#)
21 * - the number of bytes in the external representation (eg. HsInt)
22 * - the scale offset used by writeFooOffAddr#
24 * In the heap, the type may take up more space: eg. SIZEOF_INT8 == 1,
25 * but it takes up SIZEOF_HSWORD (4 or 8) bytes in the heap.
28 /* First, check some assumptions.. */
30 #error GHC untested on this architecture: sizeof(char) != 1
34 #error GHC untested on this architecture: sizeof(short) != 2
37 #if SIZEOF_UNSIGNED_INT != 4
38 #error GHC untested on this architecture: sizeof(unsigned int) != 4
41 #define SIZEOF_HSCHAR SIZEOF_WORD32
42 #define ALIGNMENT_HSCHAR ALIGNMENT_WORD32
44 #define SIZEOF_HSINT SIZEOF_VOID_P
45 #define ALIGNMENT_HSINT ALIGNMENT_VOID_P
47 #define SIZEOF_HSWORD SIZEOF_VOID_P
48 #define ALIGNMENT_HSWORD ALIGNMENT_VOID_P
50 #define SIZEOF_HSDOUBLE SIZEOF_DOUBLE
51 #define ALIGNMENT_HSDOUBLE ALIGNMENT_DOUBLE
53 #define SIZEOF_HSFLOAT SIZEOF_FLOAT
54 #define ALIGNMENT_HSFLOAT ALIGNMENT_FLOAT
56 #define SIZEOF_HSPTR SIZEOF_VOID_P
57 #define ALIGNMENT_HSPTR ALIGNMENT_VOID_P
59 #define SIZEOF_HSFUNPTR SIZEOF_VOID_P
60 #define ALIGNMENT_HSFUNPTR ALIGNMENT_VOID_P
62 #define SIZEOF_HSFOREIGNPTR SIZEOF_VOID_P
63 #define ALIGNMENT_HSFOREIGNPTR 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
109 #endif /* MACHDEPS_H */