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