summaryrefslogtreecommitdiff
path: root/rts/Stable.h
blob: 0a1cc0dd2f5b0ba844532ed0c087c5ba86f82ff2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/* -----------------------------------------------------------------------------
 *
 * (c) The GHC Team, 1998-2004
 *
 * Stable Pointers: A stable pointer is represented as an index into
 * the stable pointer table.
 *
 * StgStablePtr used to be a synonym for StgWord, but stable pointers
 * are guaranteed to be void* on the C-side, so we have to do some
 * occasional casting. Size is not a matter, because StgWord is always
 * the same size as a void*.
 *
 * ---------------------------------------------------------------------------*/

#ifndef STABLE_H
#define STABLE_H

#include "sm/GC.h" // for evac_fn below

#include "BeginPrivate.h"

void    freeStablePtr         ( StgStablePtr sp );

/* Use the "Unsafe" one after manually locking with stableLock/stableUnlock */
void    freeStablePtrUnsafe   ( StgStablePtr sp );

void    initStableTables      ( void );
void    exitStableTables      ( void );
StgWord lookupStableName      ( StgPtr p );

/* Call given function on every stable ptr. markStableTables depends
 * on the function updating its pointers in case the object is
 * moved. */
/* TODO: This also remembers old stable name addresses, which isn't
 * necessary in some contexts markStableTables is called from.
 * Consider splitting it.
 */
void    markStableTables      ( evac_fn evac, void *user );

void    threadStableTables    ( evac_fn evac, void *user );
void    gcStableTables        ( void );
void    updateStableTables    ( rtsBool full );

void    stableLock            ( void );
void    stableUnlock          ( void );

#ifdef THREADED_RTS
// needed by Schedule.c:forkProcess()
extern Mutex stable_mutex;
#endif

#include "EndPrivate.h"

#endif /* STABLE_H */

// Local Variables:
// mode: C
// fill-column: 80
// indent-tabs-mode: nil
// c-basic-offset: 4
// buffer-file-coding-system: utf-8-unix
// End: