Improve handling of -fdph-* flags
[ghc.git] / includes / Stable.h
1 /* -----------------------------------------------------------------------------
2 *
3 * (c) The GHC Team, 1998-2004
4 *
5 * Stable Pointers: A stable pointer is represented as an index into
6 * the stable pointer table in the low BITS_PER_WORD-8 bits with a
7 * weight in the upper 8 bits.
8 *
9 * SUP: StgStablePtr used to be a synonym for StgWord, but stable pointers
10 * are guaranteed to be void* on the C-side, so we have to do some occasional
11 * casting. Size is not a matter, because StgWord is always the same size as
12 * a void*.
13 *
14 * ---------------------------------------------------------------------------*/
15
16 #ifndef STABLE_H
17 #define STABLE_H
18
19 /* -----------------------------------------------------------------------------
20 External C Interface
21 -------------------------------------------------------------------------- */
22
23 extern StgPtr deRefStablePtr(StgStablePtr stable_ptr);
24 extern void freeStablePtr(StgStablePtr sp);
25 extern StgStablePtr splitStablePtr(StgStablePtr sp);
26 extern StgStablePtr getStablePtr(StgPtr p);
27
28 /* -----------------------------------------------------------------------------
29 PRIVATE from here.
30 -------------------------------------------------------------------------- */
31
32 typedef struct {
33 StgPtr addr; /* Haskell object, free list, or NULL */
34 StgPtr old; /* old Haskell object, used during GC */
35 StgWord ref; /* used for reference counting */
36 StgClosure *sn_obj; /* the StableName object (or NULL) */
37 } snEntry;
38
39 extern DLL_IMPORT_RTS snEntry *stable_ptr_table;
40
41 extern void freeStablePtr(StgStablePtr sp);
42
43 #if defined(__GNUC__)
44 # ifndef RTS_STABLE_C
45 extern inline
46 # endif
47 StgPtr deRefStablePtr(StgStablePtr sp)
48 {
49 ASSERT(stable_ptr_table[(StgWord)sp].ref > 0);
50 return stable_ptr_table[(StgWord)sp].addr;
51 }
52 #else
53 /* No support for 'extern inline' */
54 extern StgPtr deRefStablePtr(StgStablePtr sp);
55 #endif
56
57 extern void initStablePtrTable ( void );
58 extern void exitStablePtrTable ( void );
59 extern void enlargeStablePtrTable ( void );
60 extern StgWord lookupStableName ( StgPtr p );
61
62 extern void markStablePtrTable ( evac_fn evac, void *user );
63 extern void threadStablePtrTable ( evac_fn evac, void *user );
64 extern void gcStablePtrTable ( void );
65 extern void updateStablePtrTable ( rtsBool full );
66
67 extern void exitHashTable ( void );
68
69 #endif