cpp: Use #pragma once instead of #ifndef guards
[ghc.git] / rts / sm / CNF.h
1 /* -----------------------------------------------------------------------------
2 *
3 * (c) The GHC Team 1998-2014
4 *
5 * GC support for immutable non-GCed structures
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
18 void initCompact (void);
19 void exitCompact (void);
20
21 StgCompactNFData *compactNew (Capability *cap,
22 StgWord size);
23 void compactResize(Capability *cap,
24 StgCompactNFData *str,
25 StgWord new_size);
26 void compactFree (StgCompactNFData *str);
27 void compactMarkKnown(StgCompactNFData *str);
28 StgWord compactContains(StgCompactNFData *str,
29 StgPtr what);
30 StgWord countCompactBlocks(bdescr *outer);
31
32 #ifdef DEBUG
33 StgWord countAllocdCompactBlocks(bdescr *outer);
34 #endif
35
36 StgCompactNFDataBlock *compactAllocateBlock(Capability *cap,
37 StgWord size,
38 StgCompactNFDataBlock *previous);
39 StgPtr compactFixupPointers(StgCompactNFData *str,
40 StgClosure *root);
41
42 // Go from an arbitrary pointer into any block of a compact chain, to the
43 // StgCompactNFDataBlock at the beginning of the block.
44 INLINE_HEADER StgCompactNFDataBlock *objectGetCompactBlock (StgClosure *closure);
45 INLINE_HEADER StgCompactNFDataBlock *objectGetCompactBlock (StgClosure *closure)
46 {
47 bdescr *object_block, *head_block;
48
49 object_block = Bdescr((StgPtr)closure);
50
51 ASSERT ((object_block->flags & BF_COMPACT) != 0);
52
53 if (object_block->blocks == 0)
54 head_block = object_block->link;
55 else
56 head_block = object_block;
57
58 ASSERT ((head_block->flags & BF_COMPACT) != 0);
59
60 return (StgCompactNFDataBlock*)(head_block->start);
61 }
62
63 // Go from an arbitrary pointer into any block of a compact chain, to the
64 // StgCompactNFData for the whole compact chain.
65 INLINE_HEADER StgCompactNFData *objectGetCompact (StgClosure *closure);
66 INLINE_HEADER StgCompactNFData *objectGetCompact (StgClosure *closure)
67 {
68 StgCompactNFDataBlock *block = objectGetCompactBlock (closure);
69 return block->owner;
70 }
71
72 extern void *allocateForCompact (Capability *cap,
73 StgCompactNFData *str,
74 StgWord sizeW);
75
76 extern void insertCompactHash (Capability *cap,
77 StgCompactNFData *str,
78 StgClosure *p, StgClosure *to);
79
80 extern void verifyCompact (StgCompactNFData *str);
81
82 #include "EndPrivate.h"