f6a9bc9251b4d873e005d85357c30a7f7a4aac88
[ghc-hetmet.git] / ghc / includes / MachDeps.h
1 /* -----------------------------------------------------------------------------
2  * $Id: MachDeps.h,v 1.6 2001/08/17 17:18:53 apt Exp $
3  *
4  * (c) The GRASP/AQUA Project, Glasgow University, 1998
5  * (c) The GHC Team, 1998-1999
6  * 
7  * Definitions that characterise machine specific properties of basic
8  * Stg types provided as unboxed types (mirrors the typedefs in
9  * StgTypes.)
10  *
11  * NB: THIS FILE IS INCLUDED IN HASKELL SOURCE!
12  * ---------------------------------------------------------------------------*/
13
14 #ifndef MACHDEPS_H
15 #define MACHDEPS_H
16
17 #include "config.h"
18
19
20
21 #define CHAR_SIZE_IN_BYTES      1
22 #define ADDR_SIZE_IN_BYTES      SIZEOF_VOID_P
23 #define INT_SIZE_IN_BYTES       SIZEOF_LONG
24 #define WORD_SIZE_IN_BYTES      SIZEOF_LONG
25
26 #ifndef WORD_SIZE_IN_BITS
27 #if WORD_SIZE_IN_BYTES == 4
28 #define WORD_SIZE_IN_BITS       32
29 #else 
30 #define WORD_SIZE_IN_BITS       64
31 #endif
32 #endif
33
34 #define FLOAT_SIZE_IN_BYTES     SIZEOF_FLOAT
35 #define DOUBLE_SIZE_IN_BYTES    SIZEOF_DOUBLE
36
37 #define SIZEOF_INT8             SIZEOF_CHAR
38 #define ALIGNMENT_INT8          ALIGNMENT_CHAR
39 #define SIZEOF_WORD8            SIZEOF_UNSIGNED_CHAR
40 #define ALIGNMENT_WORD8         ALIGNMENT_UNSIGNED_CHAR
41
42 #define SIZEOF_INT16            SIZEOF_SHORT
43 #define ALIGNMENT_INT16         ALIGNMENT_SHORT
44 #define SIZEOF_WORD16           SIZEOF_UNSIGNED_SHORT
45 #define ALIGNMENT_WORD16        ALIGNMENT_UNSIGNED_SHORT
46
47 #if SIZEOF_UNSIGNED_INT == 4
48 #define SIZEOF_INT32            SIZEOF_INT
49 #define ALIGNMENT_INT32         ALIGNMENT_INT
50 #define SIZEOF_WORD32           SIZEOF_UNSIGNED_INT
51 #define ALIGNMENT_WORD32        ALIGNMENT_UNSIGNED_INT
52 #else
53 #error GHC untested on this architecture: sizeof(unsigned int) != 4
54 #endif
55
56 #if HAVE_LONG_LONG && SIZEOF_VOID_P < 8
57 /* assume long long is 64 bits */
58 #define SIZEOF_INT64            SIZEOF_LONG_LONG
59 #define ALIGNMENT_INT64         ALIGNMENT_LONG_LONG
60 #define SIZEOF_WORD64           SIZEOF_UNSIGNED_LONG_LONG
61 #define ALIGNMENT_WORD64        ALIGNMENT_UNSIGNED_LONG_LONG
62 #elif SIZEOF_LONG == 8
63 #define SIZEOF_INT64            SIZEOF_LONG
64 #define ALIGNMENT_INT64         ALIGNMENT_LONG
65 #define SIZEOF_WORD64           SIZEOF_UNSIGNED_LONG
66 #define ALIGNMENT_WORD64        ALIGNMENT_UNSIGNED_LONG
67 #else
68 #error GHC untested on this architecture: sizeof(void *) < 8 and no long longs.
69 #endif
70
71 #endif