RTS tidyup sweep, first phase
[ghc.git] / includes / rts / Stable.h
1 /* -----------------------------------------------------------------------------
2 *
3 * (c) The GHC Team, 1998-2004
4 *
5 * Stable Pointers
6 *
7 * ---------------------------------------------------------------------------*/
8
9 #ifndef RTS_STABLE_H
10 #define RTS_STABLE_H
11
12 EXTERN_INLINE StgPtr deRefStablePtr (StgStablePtr stable_ptr);
13 StgStablePtr getStablePtr (StgPtr p);
14
15 /* -----------------------------------------------------------------------------
16 PRIVATE from here.
17 -------------------------------------------------------------------------- */
18
19 typedef struct {
20 StgPtr addr; /* Haskell object, free list, or NULL */
21 StgPtr old; /* old Haskell object, used during GC */
22 StgWord ref; /* used for reference counting */
23 StgClosure *sn_obj; /* the StableName object (or NULL) */
24 } snEntry;
25
26 extern DLL_IMPORT_RTS snEntry *stable_ptr_table;
27
28 EXTERN_INLINE
29 StgPtr deRefStablePtr(StgStablePtr sp)
30 {
31 ASSERT(stable_ptr_table[(StgWord)sp].ref > 0);
32 return stable_ptr_table[(StgWord)sp].addr;
33 }
34
35 #endif /* RTS_STABLE_H */