[project @ 1996-01-08 20:28:12 by partain]
[ghc-hetmet.git] / ghc / includes / StgMachDeps.h
1 #ifndef STGMACHDEPS_H
2 #define STGMACHDEPS_H
3
4 #define COMMENT__(a)
5
6 COMMENT__(The COMMON_ITBLS macro determines whether we use commoned-up
7   info tables and rep tables instead of the old info table system.)
8
9 #define COMMON_ITBLS 1
10
11
12 COMMENT__(This code has to go through a Haskell compiler too)
13
14 COMMENT__(We assume 8 bit bytes.)
15 #define BITS_PER_BYTE 8
16 #define BITS_IN(x) (BITS_PER_BYTE * sizeof(x))
17
18 #ifdef __STDC__
19 #define PROTO(x)        x
20 #define NON_PROTO(x)    /* nothing */
21 #define STG_VOLATILE    volatile
22 #define STG_NO_ARGS     void
23 #define CAT2(a,b) a##b
24 #define CAT3(a,b,c) a##b##c
25 #define CAT4(a,b,c,d) a##b##c##d
26 #define CAT5(a,b,c,d,e) a##b##c##d##e
27 #define CAT6(a,b,c,d,e,f) a##b##c##d##e##f
28
29 #else
30 #define PROTO(x)        ()
31 #define NON_PROTO(x)    x
32 #define STG_VOLATILE    /* no volatile */
33 #define STG_NO_ARGS     /* no such thing either */
34 #define CAT2(a,b) a/**/b
35 #define CAT3(a,b,c) a/**/b/**/c
36 #define CAT4(a,b,c,d) a/**/b/**/c/**/d
37 #define CAT5(a,b,c,d,e) a/**/b/**/c/**/d/**/e
38 #define CAT6(a,b,c,d,e,f) a/**/b/**/c/**/d/**/e/**/f
39 #endif /* ! __STDC__ */
40
41 #ifdef __GNUC__
42 #define STG_NORETURN    __attribute__((noreturn))
43 #define STG_INLINE __inline__
44 #else
45 #define STG_NORETURN    /* no such thing */
46 #define STG_INLINE /* no inline functions */
47 #endif
48
49 #if 0
50 ------------------------------------------------------------------------
51   Steve Maguires "Writing Solid Code" suggests that (in the debugging
52   version) we should work hard to make bugs show themselves at the
53   earliest possible moment.  
54
55   In particular, it suggests that the memory management system should
56   trash memory when it is allocated and when it is deallocated so that
57   references to uninitialised memory or to released memory will show up
58   as the bugs they are.
59
60   By "trashing", I mean writing easily recognisable "nonsense" bit
61   patterns over the block of memory.  It is worth taking some care to
62   choose values which:
63
64   1) Are meaningless pointers (ideally causing memory exceptions)
65
66      (eg not word-aligned)
67
68   2) Are "weird-looking" integers (whether treated as 8, 16, 32 or 64
69      bits) (A large (definately non-zero) value).
70
71   3) Make strange-looking strings when concatenated.
72
73   4) Are meaningless machine code (ideally causing exceptions)
74
75   We should also choose different values for initialisation and
76   deallocation to make it easier to identify the source of the bug.
77
78   ADR
79 ------------------------------------------------------------------------
80 #endif /* 0 */
81
82
83 #if alpha_TARGET_ARCH
84 #define DEALLOCATED_TRASH   0xdeadbeefdeadbeef
85 #else
86 #define DEALLOCATED_TRASH   0xdeadbeef
87 #endif
88
89 #endif /* ! STGMACHDEPS_H */