Prefer #if defined to #ifdef
[ghc.git] / rts / RetainerProfile.h
1 /* -----------------------------------------------------------------------------
2 *
3 * (c) The GHC Team, 2001
4 * Author: Sungwoo Park
5 *
6 * Retainer profiling interface.
7 *
8 * ---------------------------------------------------------------------------*/
9
10 #pragma once
11
12 #if defined(PROFILING)
13
14 #include "RetainerSet.h"
15
16 #include "BeginPrivate.h"
17
18 void initRetainerProfiling ( void );
19 void endRetainerProfiling ( void );
20 void retainerProfile ( void );
21 void resetStaticObjectForRetainerProfiling( StgClosure *static_objects );
22
23 // flip is either 1 or 0, changed at the beginning of retainerProfile()
24 // It is used to tell whether a retainer set has been touched so far
25 // during this pass.
26 extern StgWord flip;
27
28 // extract the retainer set field from c
29 #define RSET(c) ((c)->header.prof.hp.rs)
30
31 #define isRetainerSetFieldValid(c) \
32 ((((StgWord)(c)->header.prof.hp.rs & 1) ^ flip) == 0)
33
34 static inline RetainerSet *
35 retainerSetOf( const StgClosure *c )
36 {
37 ASSERT( isRetainerSetFieldValid(c) );
38 // StgWord has the same size as pointers, so the following type
39 // casting is okay.
40 return (RetainerSet *)((StgWord)RSET(c) ^ flip);
41 }
42
43 // Used by Storage.c:memInventory()
44 #if defined(DEBUG)
45 extern W_ retainerStackBlocks ( void );
46 #endif
47
48 #include "EndPrivate.h"
49
50 #endif /* PROFILING */