cpp: Use #pragma once instead of #ifndef guards
[ghc.git] / rts / sm / MarkStack.h
1 /* -----------------------------------------------------------------------------
2 *
3 * (c) The GHC Team 1998-2009
4 *
5 * Operations on the mark stack
6 *
7 * Documentation on the architecture of the Garbage Collector can be
8 * found in the online commentary:
9 *
10 * http://ghc.haskell.org/trac/ghc/wiki/Commentary/Rts/Storage/GC
11 *
12 * ---------------------------------------------------------------------------*/
13
14 #pragma once
15
16 #include "BeginPrivate.h"
17 #include "GCUtils.h"
18
19 INLINE_HEADER void
20 push_mark_stack(StgPtr p)
21 {
22 bdescr *bd;
23
24 *mark_sp++ = (StgWord)p;
25
26 if (((W_)mark_sp & BLOCK_MASK) == 0)
27 {
28 if (mark_stack_bd->u.back != NULL)
29 {
30 mark_stack_bd = mark_stack_bd->u.back;
31 }
32 else
33 {
34 bd = allocBlock_sync();
35 bd->link = mark_stack_bd;
36 bd->u.back = NULL;
37 mark_stack_bd->u.back = bd; // double-link the new block on
38 mark_stack_top_bd = bd;
39 mark_stack_bd = bd;
40 }
41 mark_sp = mark_stack_bd->start;
42 }
43 }
44
45 INLINE_HEADER StgPtr
46 pop_mark_stack(void)
47 {
48 if (((W_)mark_sp & BLOCK_MASK) == 0)
49 {
50 if (mark_stack_bd->link == NULL)
51 {
52 return NULL;
53 }
54 else
55 {
56 mark_stack_bd = mark_stack_bd->link;
57 mark_sp = mark_stack_bd->start + BLOCK_SIZE_W;
58 }
59 }
60 return (StgPtr)*--mark_sp;
61 }
62
63 INLINE_HEADER bool
64 mark_stack_empty(void)
65 {
66 return (((W_)mark_sp & BLOCK_MASK) == 0 && mark_stack_bd->link == NULL);
67 }
68
69 #include "EndPrivate.h"