f953613c657faf11e24d02a7be11d8dd85f8b155
[ghc-hetmet.git] / ghc / rts / StoragePriv.h
1 /* -----------------------------------------------------------------------------
2  * $Id: StoragePriv.h,v 1.15 2001/07/23 17:23:20 simonmar Exp $
3  *
4  * (c) The GHC Team, 1998-1999
5  *
6  * Internal Storage Manger Interface
7  *
8  * ---------------------------------------------------------------------------*/
9
10 #ifndef STORAGEPRIV_H
11 #define STORAGEPRIV_H
12
13 #define END_OF_STATIC_LIST stgCast(StgClosure*,1)
14
15 extern generation *generations;
16
17 extern generation *g0;
18 extern step *g0s0;
19 extern generation *oldest_gen;
20
21 extern void newCAF(StgClosure*);
22
23 extern void move_TSO(StgTSO *src, StgTSO *dest);
24 extern StgTSO *relocate_stack(StgTSO *dest, int diff);
25
26 extern StgClosure *static_objects;
27 extern StgClosure *scavenged_static_objects;
28
29 extern StgWeak    *weak_ptr_list;
30 extern StgClosure *caf_list;
31
32 extern bdescr *small_alloc_list;
33 extern bdescr *large_alloc_list;
34
35 extern StgPtr alloc_Hp;
36 extern StgPtr alloc_HpLim;
37
38 extern bdescr *nursery;
39
40 extern nat nursery_blocks;
41 extern nat alloc_blocks;
42 extern nat alloc_blocks_lim;
43
44 extern lnat total_allocated;
45
46 /* Nursery manipulation */
47 extern void     allocNurseries ( void );
48 extern void     resetNurseries ( void );
49 extern bdescr * allocNursery   ( bdescr *last_bd, nat blocks );
50 extern void     resizeNursery  ( nat blocks );
51
52 /* Stats 'n' stuff */
53 extern lnat calcAllocated  ( void );
54 extern lnat calcLive       ( void );
55 extern lnat calcNeeded     ( void );
56
57 static inline void
58 dbl_link_onto(bdescr *bd, bdescr **list)
59 {
60   bd->link = *list;
61   bd->u.back = NULL;
62   if (*list) {
63     (*list)->u.back = bd; /* double-link the list */
64   }
65   *list = bd;
66 }
67
68 /* MUTABLE LISTS
69  * A mutable list is ended with END_MUT_LIST, so that we can use NULL
70  * as an indication that an object is not on a mutable list.
71  */
72 #define END_MUT_LIST ((StgMutClosure *)(void *)&stg_END_MUT_LIST_closure)
73
74 #ifdef DEBUG
75 extern void memInventory(void);
76 extern void checkSanity(void);
77 #endif
78
79 /* 
80  * These three are used by the garbage collector when we have
81  * dynamically-linked object modules.  (see ClosureMacros.h,
82  * IS_CODE_PTR etc.). 
83  * Defined in Linker.c.
84  */
85 int is_dynamically_loaded_code_or_rodata_ptr ( void* p );
86 int is_dynamically_loaded_rwdata_ptr         ( void* p );
87 int is_not_dynamically_loaded_ptr            ( void* p );
88
89 /* Functions from GC.c 
90  */
91 void threadPaused(StgTSO *);
92 StgClosure *isAlive(StgClosure *p);
93
94 #endif /* STORAGEPRIV_H */