1 /* -----------------------------------------------------------------------------
2 * $Id: MachDeps.h,v 1.7 2001/10/03 13:57:42 simonmar Exp $
4 * (c) The GRASP/AQUA Project, Glasgow University, 1998
5 * (c) The GHC Team, 1998-1999
6 * (c) The University of Glasgow 2001
8 * Definitions that characterise machine specific properties of basic
11 * NB: Keep in sync with HsFFI.h and StgTypes.h.
12 * NB: THIS FILE IS INCLUDED IN HASKELL SOURCE!
13 * ---------------------------------------------------------------------------*/
18 /* Sizes of C types come from here... */
21 /* Sizes of Haskell types follow. These sizes correspond to:
22 * - the number of bytes in the primitive type (eg. Int#)
23 * - the number of bytes in the external representation (eg. HsInt)
24 * - the scale offset used by writeFooOffAddr#
26 * In the heap, the type may take up more space: eg. SIZEOF_INT8 == 1,
27 * but it takes up SIZEOF_HSWORD (4 or 8) bytes in the heap.
30 /* First, check some assumptions.. */
32 #error GHC untested on this architecture: sizeof(char) != 1
36 #error GHC untested on this architecture: sizeof(short) != 2
39 #if SIZEOF_UNSIGNED_INT != 4
40 #error GHC untested on this architecture: sizeof(unsigned int) != 4
43 #define SIZEOF_HSCHAR SIZEOF_WORD32
44 #define ALIGNMENT_HSCHAR ALIGNMENT_WORD32
46 #define SIZEOF_HSINT SIZEOF_VOID_P
47 #define ALIGNMENT_HSINT ALIGNMENT_VOID_P
49 #define SIZEOF_HSWORD SIZEOF_VOID_P
50 #define ALIGNMENT_HSWORD ALIGNMENT_VOID_P
52 #define SIZEOF_HSDOUBLE SIZEOF_DOUBLE
53 #define ALIGNMENT_HSDOUBLE ALIGNMENT_DOUBLE
55 #define SIZEOF_HSFLOAT SIZEOF_FLOAT
56 #define ALIGNMENT_HSFLOAT ALIGNMENT_FLOAT
58 #define SIZEOF_HSPTR SIZEOF_VOID_P
59 #define ALIGNMENT_HSPTR ALIGNMENT_VOID_P
61 #define SIZEOF_HSFUNPTR SIZEOF_VOID_P
62 #define ALIGNMENT_HSFUNPTR ALIGNMENT_VOID_P
64 #define SIZEOF_HSFOREIGNPTR SIZEOF_VOID_P
65 #define ALIGNMENT_HSFOREIGNPTR ALIGNMENT_VOID_P
67 #define SIZEOF_HSSTABLEPTR SIZEOF_VOID_P
68 #define ALIGNMENT_HSSTABLEPTR ALIGNMENT_VOID_P
70 #define SIZEOF_INT8 SIZEOF_CHAR
71 #define ALIGNMENT_INT8 ALIGNMENT_CHAR
73 #define SIZEOF_WORD8 SIZEOF_UNSIGNED_CHAR
74 #define ALIGNMENT_WORD8 ALIGNMENT_UNSIGNED_CHAR
76 #define SIZEOF_INT16 SIZEOF_SHORT
77 #define ALIGNMENT_INT16 ALIGNMENT_SHORT
79 #define SIZEOF_WORD16 SIZEOF_UNSIGNED_SHORT
80 #define ALIGNMENT_WORD16 ALIGNMENT_UNSIGNED_SHORT
82 #define SIZEOF_INT32 SIZEOF_INT
83 #define ALIGNMENT_INT32 ALIGNMENT_INT
85 #define SIZEOF_WORD32 SIZEOF_UNSIGNED_INT
86 #define ALIGNMENT_WORD32 ALIGNMENT_UNSIGNED_INT
88 #if HAVE_LONG_LONG && SIZEOF_VOID_P < 8
89 /* assume long long is 64 bits */
90 #define SIZEOF_INT64 SIZEOF_LONG_LONG
91 #define ALIGNMENT_INT64 ALIGNMENT_LONG_LONG
92 #define SIZEOF_WORD64 SIZEOF_UNSIGNED_LONG_LONG
93 #define ALIGNMENT_WORD64 ALIGNMENT_UNSIGNED_LONG_LONG
94 #elif SIZEOF_LONG == 8
95 #define SIZEOF_INT64 SIZEOF_LONG
96 #define ALIGNMENT_INT64 ALIGNMENT_LONG
97 #define SIZEOF_WORD64 SIZEOF_UNSIGNED_LONG
98 #define ALIGNMENT_WORD64 ALIGNMENT_UNSIGNED_LONG
100 #error GHC untested on this architecture: sizeof(void *) < 8 and no long longs.
103 #ifndef WORD_SIZE_IN_BITS
104 #if SIZEOF_HSWORD == 4
105 #define WORD_SIZE_IN_BITS 32
107 #define WORD_SIZE_IN_BITS 64
111 #endif /* MACHDEPS_H */