1 /* -----------------------------------------------------------------------------
2 * $Id: Stable.h,v 1.15 2003/11/12 17:27:03 sof Exp $
4 * (c) The GHC Team, 1998-2000
6 * Stable Pointers: A stable pointer is represented as an index into
7 * the stable pointer table in the low BITS_PER_WORD-8 bits with a
8 * weight in the upper 8 bits.
10 * SUP: StgStablePtr used to be a synonym for StgWord, but stable pointers
11 * are guaranteed to be void* on the C-side, so we have to do some occasional
12 * casting. Size is not a matter, because StgWord is always the same size as
15 * ---------------------------------------------------------------------------*/
20 /* -----------------------------------------------------------------------------
22 -------------------------------------------------------------------------- */
24 extern StgPtr deRefStablePtr(StgStablePtr stable_ptr);
25 extern void freeStablePtr(StgStablePtr sp);
26 extern StgStablePtr splitStablePtr(StgStablePtr sp);
27 extern StgStablePtr getStablePtr(StgPtr p);
29 /* -----------------------------------------------------------------------------
31 -------------------------------------------------------------------------- */
34 StgPtr addr; /* Haskell object, free list, or NULL */
35 StgPtr old; /* old Haskell object, used during GC */
36 StgWord ref; /* used for reference counting */
37 StgClosure *sn_obj; /* the StableName object (or NULL) */
40 extern DLL_IMPORT_RTS snEntry *stable_ptr_table;
42 extern void freeStablePtr(StgStablePtr sp);
48 StgPtr deRefStablePtr(StgStablePtr sp)
50 ASSERT(stable_ptr_table[(StgWord)sp].ref > 0);
51 return stable_ptr_table[(StgWord)sp].addr;
54 /* No support for 'extern inline' */
55 extern StgPtr deRefStablePtr(StgStablePtr sp);