MachDeps.h 2.92 KB
Newer Older
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 17 18
 * ---------------------------------------------------------------------------*/

#ifndef MACHDEPS_H
#define MACHDEPS_H

19
/* Sizes of C types come from here... */
20
#include "ghcautoconf.h"
21

22 23 24 25 26 27 28 29
/* Sizes of Haskell types follow.  These sizes correspond to:
 *   - the number of bytes in the primitive type (eg. Int#)
 *   - the number of bytes in the external representation (eg. HsInt)
 *   - the scale offset used by writeFooOffAddr#
 *
 * In the heap, the type may take up more space: eg. SIZEOF_INT8 == 1,
 * but it takes up SIZEOF_HSWORD (4 or 8) bytes in the heap.
 */
apt's avatar
apt committed
30

31 32 33 34 35 36
#define SIZEOF_HSCHAR           SIZEOF_WORD32
#define ALIGNMENT_HSCHAR        ALIGNMENT_WORD32

#define SIZEOF_HSINT            SIZEOF_VOID_P
#define ALIGNMENT_HSINT         ALIGNMENT_VOID_P

dterei's avatar
dterei committed
37 38
#define SIZEOF_HSWORD           SIZEOF_VOID_P
#define ALIGNMENT_HSWORD        ALIGNMENT_VOID_P
39

dterei's avatar
dterei committed
40 41
#define SIZEOF_HSDOUBLE         SIZEOF_DOUBLE
#define ALIGNMENT_HSDOUBLE      ALIGNMENT_DOUBLE
42

dterei's avatar
dterei committed
43 44
#define SIZEOF_HSFLOAT          SIZEOF_FLOAT
#define ALIGNMENT_HSFLOAT       ALIGNMENT_FLOAT
45 46 47 48 49 50 51 52 53

#define SIZEOF_HSPTR            SIZEOF_VOID_P
#define ALIGNMENT_HSPTR         ALIGNMENT_VOID_P

#define SIZEOF_HSFUNPTR         SIZEOF_VOID_P
#define ALIGNMENT_HSFUNPTR      ALIGNMENT_VOID_P

#define SIZEOF_HSSTABLEPTR      SIZEOF_VOID_P
#define ALIGNMENT_HSSTABLEPTR   ALIGNMENT_VOID_P
54

55 56
#define SIZEOF_INT8             SIZEOF_INT8_T
#define ALIGNMENT_INT8          ALIGNMENT_INT8_T
57

58 59
#define SIZEOF_WORD8            SIZEOF_UINT8_T
#define ALIGNMENT_WORD8         ALIGNMENT_UINT8_T
60

61 62
#define SIZEOF_INT16            SIZEOF_INT16_T
#define ALIGNMENT_INT16         ALIGNMENT_INT16_T
63

64 65
#define SIZEOF_WORD16           SIZEOF_UINT16_T
#define ALIGNMENT_WORD16        ALIGNMENT_UINT16_T
66

67 68
#define SIZEOF_INT32            SIZEOF_INT32_T
#define ALIGNMENT_INT32         ALIGNMENT_INT32_T
69

70 71
#define SIZEOF_WORD32           SIZEOF_UINT32_T
#define ALIGNMENT_WORD32        ALIGNMENT_UINT32_T
72

73 74 75 76 77
#define SIZEOF_INT64            SIZEOF_INT64_T
#define ALIGNMENT_INT64         ALIGNMENT_INT64_T

#define SIZEOF_WORD64           SIZEOF_UINT64_T
#define ALIGNMENT_WORD64        ALIGNMENT_UINT64_T
78

79 80 81
#ifndef WORD_SIZE_IN_BITS
#if SIZEOF_HSWORD == 4
#define WORD_SIZE_IN_BITS       32
Austin Seipp's avatar
Austin Seipp committed
82
#define WORD_SIZE_IN_BITS_FLOAT 32.0
83
#else
84
#define WORD_SIZE_IN_BITS       64
Austin Seipp's avatar
Austin Seipp committed
85
#define WORD_SIZE_IN_BITS_FLOAT 64.0
86
#endif
87
#endif
88

Simon Marlow's avatar
Simon Marlow committed
89 90 91
#ifndef TAG_BITS
#if SIZEOF_HSWORD == 4
#define TAG_BITS                2
92
#else
Simon Marlow's avatar
Simon Marlow committed
93 94 95 96 97 98
#define TAG_BITS                3
#endif
#endif

#define TAG_MASK ((1 << TAG_BITS) - 1)

99
#endif /* MACHDEPS_H */