Omit visibility pragmas on Windows (fixes warnings/validate failures)
[ghc.git] / rts / sm / Compact.h
1 /* -----------------------------------------------------------------------------
2 *
3 * (c) The GHC Team 1998-2008
4 *
5 * Compacting garbage collector
6 *
7 * Documentation on the architecture of the Garbage Collector can be
8 * found in the online commentary:
9 *
10 * http://hackage.haskell.org/trac/ghc/wiki/Commentary/Rts/Storage/GC
11 *
12 * ---------------------------------------------------------------------------*/
13
14 #ifndef SM_COMPACT_H
15 #define SM_COMPACT_H
16
17 BEGIN_RTS_PRIVATE
18
19 INLINE_HEADER rtsBool
20 mark_stack_empty(void)
21 {
22 return mark_sp == mark_stack;
23 }
24
25 INLINE_HEADER rtsBool
26 mark_stack_full(void)
27 {
28 return mark_sp >= mark_splim;
29 }
30
31 INLINE_HEADER void
32 reset_mark_stack(void)
33 {
34 mark_sp = mark_stack;
35 }
36
37 INLINE_HEADER void
38 push_mark_stack(StgPtr p)
39 {
40 *mark_sp++ = p;
41 }
42
43 INLINE_HEADER StgPtr
44 pop_mark_stack(void)
45 {
46 return *--mark_sp;
47 }
48
49 INLINE_HEADER void
50 mark(StgPtr p, bdescr *bd)
51 {
52 nat offset_within_block = p - bd->start; // in words
53 StgPtr bitmap_word = (StgPtr)bd->u.bitmap +
54 (offset_within_block / (sizeof(W_)*BITS_PER_BYTE));
55 StgWord bit_mask = (StgWord)1 << (offset_within_block & (sizeof(W_)*BITS_PER_BYTE - 1));
56 *bitmap_word |= bit_mask;
57 }
58
59 INLINE_HEADER void
60 unmark(StgPtr p, bdescr *bd)
61 {
62 nat offset_within_block = p - bd->start; // in words
63 StgPtr bitmap_word = (StgPtr)bd->u.bitmap +
64 (offset_within_block / (sizeof(W_)*BITS_PER_BYTE));
65 StgWord bit_mask = (StgWord)1 << (offset_within_block & (sizeof(W_)*BITS_PER_BYTE - 1));
66 *bitmap_word &= ~bit_mask;
67 }
68
69 INLINE_HEADER StgWord
70 is_marked(StgPtr p, bdescr *bd)
71 {
72 nat offset_within_block = p - bd->start; // in words
73 StgPtr bitmap_word = (StgPtr)bd->u.bitmap +
74 (offset_within_block / (sizeof(W_)*BITS_PER_BYTE));
75 StgWord bit_mask = (StgWord)1 << (offset_within_block & (sizeof(W_)*BITS_PER_BYTE - 1));
76 return (*bitmap_word & bit_mask);
77 }
78
79 void compact (StgClosure *static_objects);
80
81 END_RTS_PRIVATE
82
83 #endif /* SM_COMPACT_H */