Delete ghctags cabal file
[ghc.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) of a target platform.
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 * https://gitlab.haskell.org/ghc/ghc/wikis/commentary/source-tree/includes
13 *
14 * ---------------------------------------------------------------------------*/
15
16 #pragma once
17
18 /* Don't allow stage1 (cross-)compiler embed assumptions about target
19 * platform. When ghc-stage1 is being built by ghc-stage0 is should not
20 * refer to target defines. A few past examples:
21 * - https://gitlab.haskell.org/ghc/ghc/issues/13491
22 * - https://phabricator.haskell.org/D3122
23 * - https://phabricator.haskell.org/D3405
24 *
25 * In those cases code change assumed target defines like SIZEOF_HSINT
26 * are applied to host platform, not target platform.
27 *
28 * So what should be used instead in GHC_STAGE=1?
29 *
30 * To get host's equivalent of SIZEOF_HSINT you can use Bits instances:
31 * Data.Bits.finiteBitSize (0 :: Int)
32 *
33 * To get target's values it is preferred to use runtime target
34 * configuration from 'targetPlatform :: DynFlags -> Platform'
35 * record. A few wrappers are already defined and used throughout GHC:
36 * wORD_SIZE :: DynFlags -> Int
37 * wORD_SIZE dflags = pc_WORD_SIZE (platformConstants dflags)
38 *
39 * Hence we hide these macros from GHC_STAGE=1
40 */
41
42 /* Sizes of C types come from here... */
43 #include "ghcautoconf.h"
44
45 /* Sizes of Haskell types follow. These sizes correspond to:
46 * - the number of bytes in the primitive type (eg. Int#)
47 * - the number of bytes in the external representation (eg. HsInt)
48 * - the scale offset used by writeFooOffAddr#
49 *
50 * In the heap, the type may take up more space: eg. SIZEOF_INT8 == 1,
51 * but it takes up SIZEOF_HSWORD (4 or 8) bytes in the heap.
52 */
53
54 #define SIZEOF_HSCHAR SIZEOF_WORD32
55 #define ALIGNMENT_HSCHAR ALIGNMENT_WORD32
56
57 #define SIZEOF_HSINT SIZEOF_VOID_P
58 #define ALIGNMENT_HSINT ALIGNMENT_VOID_P
59
60 #define SIZEOF_HSWORD SIZEOF_VOID_P
61 #define ALIGNMENT_HSWORD ALIGNMENT_VOID_P
62
63 #define SIZEOF_HSDOUBLE SIZEOF_DOUBLE
64 #define ALIGNMENT_HSDOUBLE ALIGNMENT_DOUBLE
65
66 #define SIZEOF_HSFLOAT SIZEOF_FLOAT
67 #define ALIGNMENT_HSFLOAT ALIGNMENT_FLOAT
68
69 #define SIZEOF_HSPTR SIZEOF_VOID_P
70 #define ALIGNMENT_HSPTR ALIGNMENT_VOID_P
71
72 #define SIZEOF_HSFUNPTR SIZEOF_VOID_P
73 #define ALIGNMENT_HSFUNPTR ALIGNMENT_VOID_P
74
75 #define SIZEOF_HSSTABLEPTR SIZEOF_VOID_P
76 #define ALIGNMENT_HSSTABLEPTR ALIGNMENT_VOID_P
77
78 #define SIZEOF_INT8 SIZEOF_INT8_T
79 #define ALIGNMENT_INT8 ALIGNMENT_INT8_T
80
81 #define SIZEOF_WORD8 SIZEOF_UINT8_T
82 #define ALIGNMENT_WORD8 ALIGNMENT_UINT8_T
83
84 #define SIZEOF_INT16 SIZEOF_INT16_T
85 #define ALIGNMENT_INT16 ALIGNMENT_INT16_T
86
87 #define SIZEOF_WORD16 SIZEOF_UINT16_T
88 #define ALIGNMENT_WORD16 ALIGNMENT_UINT16_T
89
90 #define SIZEOF_INT32 SIZEOF_INT32_T
91 #define ALIGNMENT_INT32 ALIGNMENT_INT32_T
92
93 #define SIZEOF_WORD32 SIZEOF_UINT32_T
94 #define ALIGNMENT_WORD32 ALIGNMENT_UINT32_T
95
96 #define SIZEOF_INT64 SIZEOF_INT64_T
97 #define ALIGNMENT_INT64 ALIGNMENT_INT64_T
98
99 #define SIZEOF_WORD64 SIZEOF_UINT64_T
100 #define ALIGNMENT_WORD64 ALIGNMENT_UINT64_T
101
102 #if !defined(WORD_SIZE_IN_BITS)
103 #if SIZEOF_HSWORD == 4
104 #define WORD_SIZE_IN_BITS 32
105 #define WORD_SIZE_IN_BITS_FLOAT 32.0
106 #else
107 #define WORD_SIZE_IN_BITS 64
108 #define WORD_SIZE_IN_BITS_FLOAT 64.0
109 #endif
110 #endif
111
112 #if !defined(TAG_BITS)
113 #if SIZEOF_HSWORD == 4
114 #define TAG_BITS 2
115 #else
116 #define TAG_BITS 3
117 #endif
118 #endif
119
120 #define TAG_MASK ((1 << TAG_BITS) - 1)
121