Tidy up file headers and copyrights; point to the wiki for docs
[ghc-hetmet.git] / includes / rts / Stable.h
1 /* -----------------------------------------------------------------------------
2  *
3  * (c) The GHC Team, 1998-2009
4  *
5  * Stable Pointers
6  *
7  * Do not #include this file directly: #include "Rts.h" instead.
8  *
9  * To understand the structure of the RTS headers, see the wiki:
10  *   http://hackage.haskell.org/trac/ghc/wiki/Commentary/SourceTree/Includes
11  *
12  * ---------------------------------------------------------------------------*/
13
14 #ifndef RTS_STABLE_H
15 #define RTS_STABLE_H
16
17 EXTERN_INLINE StgPtr deRefStablePtr (StgStablePtr stable_ptr);
18 StgStablePtr getStablePtr  (StgPtr p);
19
20 /* -----------------------------------------------------------------------------
21    PRIVATE from here.
22    -------------------------------------------------------------------------- */
23
24 typedef struct { 
25   StgPtr  addr;                 /* Haskell object, free list, or NULL */
26   StgPtr  old;                  /* old Haskell object, used during GC */
27   StgWord ref;                  /* used for reference counting */
28   StgClosure *sn_obj;           /* the StableName object (or NULL) */
29 } snEntry;
30
31 extern DLL_IMPORT_RTS snEntry *stable_ptr_table;
32
33 EXTERN_INLINE
34 StgPtr deRefStablePtr(StgStablePtr sp)
35 {
36     ASSERT(stable_ptr_table[(StgWord)sp].ref > 0);
37     return stable_ptr_table[(StgWord)sp].addr;
38 }
39
40 #endif /* RTS_STABLE_H */