Commit | Line | Data |
---|---|---|
0f2d19dd JB |
1 | /* classes: h_files */ |
2 | ||
61045190 DH |
3 | #ifndef SCM_GC_H |
4 | #define SCM_GC_H | |
8c494e99 | 5 | |
61045190 | 6 | /* Copyright (C) 1995,1996,1998,1999,2000,2001 Free Software Foundation, Inc. |
a00c95d9 | 7 | * |
0f2d19dd JB |
8 | * This program is free software; you can redistribute it and/or modify |
9 | * it under the terms of the GNU General Public License as published by | |
10 | * the Free Software Foundation; either version 2, or (at your option) | |
11 | * any later version. | |
a00c95d9 | 12 | * |
0f2d19dd JB |
13 | * This program is distributed in the hope that it will be useful, |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | * GNU General Public License for more details. | |
a00c95d9 | 17 | * |
0f2d19dd JB |
18 | * You should have received a copy of the GNU General Public License |
19 | * along with this software; see the file COPYING. If not, write to | |
82892bed JB |
20 | * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, |
21 | * Boston, MA 02111-1307 USA | |
0f2d19dd JB |
22 | * |
23 | * As a special exception, the Free Software Foundation gives permission | |
24 | * for additional uses of the text contained in its release of GUILE. | |
25 | * | |
26 | * The exception is that, if you link the GUILE library with other files | |
27 | * to produce an executable, this does not by itself cause the | |
28 | * resulting executable to be covered by the GNU General Public License. | |
29 | * Your use of that executable is in no way restricted on account of | |
30 | * linking the GUILE library code into it. | |
31 | * | |
32 | * This exception does not however invalidate any other reasons why | |
33 | * the executable file might be covered by the GNU General Public License. | |
34 | * | |
35 | * This exception applies only to the code released by the | |
36 | * Free Software Foundation under the name GUILE. If you copy | |
37 | * code from other Free Software Foundation releases into a copy of | |
38 | * GUILE, as the General Public License permits, the exception does | |
39 | * not apply to the code that you add in this way. To avoid misleading | |
40 | * anyone as to the status of such modified files, you must delete | |
41 | * this exception notice from them. | |
42 | * | |
43 | * If you write modifications of your own for GUILE, it is your choice | |
44 | * whether to permit this exception to apply to your modifications. | |
82892bed | 45 | * If you do not wish that, delete this exception notice. */ |
d3a6bc94 | 46 | |
0f2d19dd JB |
47 | \f |
48 | ||
b4309c3c | 49 | #include "libguile/__scm.h" |
2549a709 | 50 | |
9b3e180c MD |
51 | #include "libguile/hooks.h" |
52 | ||
0f2d19dd JB |
53 | \f |
54 | ||
228a24ef | 55 | typedef struct scm_t_cell |
2549a709 | 56 | { |
92c2555f MV |
57 | scm_t_bits word_0; |
58 | scm_t_bits word_1; | |
228a24ef | 59 | } scm_t_cell; |
2549a709 DH |
60 | |
61 | ||
62 | /* SCM_CELLPTR is a pointer to a cons cell which may be compared or | |
63 | * differenced. | |
64 | */ | |
228a24ef | 65 | typedef scm_t_cell * SCM_CELLPTR; |
2549a709 DH |
66 | |
67 | ||
68 | /* Cray machines have pointers that are incremented once for each word, | |
69 | * rather than each byte, the 3 most significant bits encode the byte | |
70 | * within the word. The following macros deal with this by storing the | |
71 | * native Cray pointers like the ones that looks like scm expects. This | |
228a24ef | 72 | * is done for any pointers that might appear in the car of a scm_t_cell, |
e618c9a3 | 73 | * pointers to scm_vector elts, functions, &c are not munged. |
2549a709 DH |
74 | */ |
75 | #ifdef _UNICOS | |
076d6063 | 76 | # define SCM2PTR(x) ((SCM_CELLPTR) (SCM_UNPACK (x) >> 3)) |
92c2555f | 77 | # define PTR2SCM(x) (SCM_PACK (((scm_t_bits) (x)) << 3)) |
2549a709 | 78 | #else |
076d6063 | 79 | # define SCM2PTR(x) ((SCM_CELLPTR) (SCM_UNPACK (x))) |
92c2555f | 80 | # define PTR2SCM(x) (SCM_PACK ((scm_t_bits) (x))) |
2549a709 DH |
81 | #endif /* def _UNICOS */ |
82 | ||
e618c9a3 | 83 | #define SCM_GC_CARD_N_HEADER_CELLS 1 |
f91f77e6 | 84 | #define SCM_GC_CARD_N_CELLS 256 |
e618c9a3 | 85 | |
228a24ef | 86 | #define SCM_GC_CARD_SIZE (SCM_GC_CARD_N_CELLS * sizeof (scm_t_cell)) |
e618c9a3 ML |
87 | #define SCM_GC_CARD_N_DATA_CELLS (SCM_GC_CARD_N_CELLS - SCM_GC_CARD_N_HEADER_CELLS) |
88 | ||
89 | #define SCM_GC_CARD_BVEC_SIZE_IN_LIMBS \ | |
90 | ((SCM_GC_CARD_N_CELLS + SCM_C_BVEC_LIMB_BITS - 1) / SCM_C_BVEC_LIMB_BITS) | |
91 | ||
92 | #define SCM_GC_IN_CARD_HEADERP(x) \ | |
228a24ef | 93 | SCM_PTR_LT ((scm_t_cell *) (x), SCM_GC_CELL_CARD (x) + SCM_GC_CARD_N_HEADER_CELLS) |
e618c9a3 | 94 | |
92c2555f | 95 | #define SCM_GC_CARD_BVEC(card) ((scm_t_c_bvec_limb *) ((card)->word_0)) |
322ec19d | 96 | #define SCM_GC_SET_CARD_BVEC(card, bvec) \ |
92c2555f | 97 | ((card)->word_0 = (scm_t_bits) (bvec)) |
e618c9a3 | 98 | |
c014a02e | 99 | #define SCM_GC_GET_CARD_FLAGS(card) ((long) ((card)->word_1)) |
322ec19d | 100 | #define SCM_GC_SET_CARD_FLAGS(card, flags) \ |
92c2555f | 101 | ((card)->word_1 = (scm_t_bits) (flags)) |
322ec19d | 102 | #define SCM_GC_CLR_CARD_FLAGS(card) (SCM_GC_SET_CARD_FLAGS (card, 0L)) |
e618c9a3 ML |
103 | |
104 | #define SCM_GC_GET_CARD_FLAG(card, shift) (SCM_GC_GET_CARD_FLAGS (card) & (1L << (shift))) | |
322ec19d ML |
105 | #define SCM_GC_SET_CARD_FLAG(card, shift) \ |
106 | (SCM_GC_SET_CARD_FLAGS (card, SCM_GC_GET_CARD_FLAGS(card) | (1L << (shift)))) | |
107 | #define SCM_GC_CLR_CARD_FLAG(card, shift) \ | |
108 | (SCM_GC_SET_CARD_FLAGS (card, SCM_GC_GET_CARD_FLAGS(card) & ~(1L << (shift)))) | |
e618c9a3 ML |
109 | |
110 | #define SCM_GC_CARDF_DOUBLECELL 0 | |
111 | ||
112 | #define SCM_GC_CARD_DOUBLECELLP(card) SCM_GC_GET_CARD_FLAG (card, SCM_GC_CARDF_DOUBLECELL) | |
113 | #define SCM_GC_SET_CARD_DOUBLECELL(card) SCM_GC_SET_CARD_FLAG (card, SCM_GC_CARDF_DOUBLECELL) | |
114 | ||
115 | /* card addressing. for efficiency, cards are *always* aligned to | |
116 | SCM_GC_CARD_SIZE. */ | |
117 | ||
118 | #define SCM_GC_CARD_SIZE_MASK (SCM_GC_CARD_SIZE - 1) | |
119 | #define SCM_GC_CARD_ADDR_MASK (~SCM_GC_CARD_SIZE_MASK) | |
120 | ||
c014a02e | 121 | #define SCM_GC_CELL_CARD(x) ((SCM_CELLPTR) ((long) (x) & SCM_GC_CARD_ADDR_MASK)) |
e618c9a3 | 122 | #define SCM_GC_CELL_SPAN(x) ((SCM_GC_CARD_DOUBLECELLP (SCM_GC_CELL_CARD (x))) ? 2 : 1) |
c014a02e | 123 | #define SCM_GC_CELL_OFFSET(x) (((long) (x) & SCM_GC_CARD_SIZE_MASK) >> SCM_CELL_SIZE_SHIFT) |
e618c9a3 ML |
124 | #define SCM_GC_CELL_BVEC(x) SCM_GC_CARD_BVEC (SCM_GC_CELL_CARD (x)) |
125 | #define SCM_GC_CELL_GET_BIT(x) SCM_C_BVEC_GET (SCM_GC_CELL_BVEC (x), SCM_GC_CELL_OFFSET (x)) | |
126 | #define SCM_GC_CELL_SET_BIT(x) SCM_C_BVEC_SET (SCM_GC_CELL_BVEC (x), SCM_GC_CELL_OFFSET (x)) | |
127 | #define SCM_GC_CELL_CLR_BIT(x) SCM_C_BVEC_CLR (SCM_GC_CELL_BVEC (x), SCM_GC_CELL_OFFSET (x)) | |
128 | ||
129 | #define SCM_GC_CARD_UP(x) SCM_GC_CELL_CARD ((char *) (x) + SCM_GC_CARD_SIZE - 1) | |
130 | #define SCM_GC_CARD_DOWN SCM_GC_CELL_CARD | |
131 | ||
132 | /* low level bit banging aids */ | |
133 | ||
92c2555f | 134 | typedef unsigned long scm_t_c_bvec_limb; |
e618c9a3 ML |
135 | |
136 | #if (SIZEOF_LONG == 8) | |
137 | # define SCM_C_BVEC_LIMB_BITS 64 | |
138 | # define SCM_C_BVEC_OFFSET_SHIFT 6 | |
139 | # define SCM_C_BVEC_POS_MASK 63 | |
140 | # define SCM_CELL_SIZE_SHIFT 4 | |
141 | #else | |
142 | # define SCM_C_BVEC_LIMB_BITS 32 | |
143 | # define SCM_C_BVEC_OFFSET_SHIFT 5 | |
144 | # define SCM_C_BVEC_POS_MASK 31 | |
145 | # define SCM_CELL_SIZE_SHIFT 3 | |
146 | #endif | |
147 | ||
148 | #define SCM_C_BVEC_OFFSET(pos) (pos >> SCM_C_BVEC_OFFSET_SHIFT) | |
149 | ||
150 | #define SCM_C_BVEC_GET(bvec, pos) (bvec[SCM_C_BVEC_OFFSET (pos)] & (1L << (pos & SCM_C_BVEC_POS_MASK))) | |
151 | #define SCM_C_BVEC_SET(bvec, pos) (bvec[SCM_C_BVEC_OFFSET (pos)] |= (1L << (pos & SCM_C_BVEC_POS_MASK))) | |
152 | #define SCM_C_BVEC_CLR(bvec, pos) (bvec[SCM_C_BVEC_OFFSET (pos)] &= ~(1L << (pos & SCM_C_BVEC_POS_MASK))) | |
153 | ||
154 | #define SCM_C_BVEC_BITS2BYTES(bits) \ | |
92c2555f | 155 | (sizeof (scm_t_c_bvec_limb) * ((((bits) & SCM_C_BVEC_POS_MASK) ? 1L : 0L) + SCM_C_BVEC_OFFSET (bits))) |
e618c9a3 ML |
156 | |
157 | #define SCM_C_BVEC_SET_BYTES(bvec, bytes) (memset (bvec, 0xff, bytes)) | |
158 | #define SCM_C_BVEC_SET_ALL_BITS(bvec, bits) SCM_C_BVEC_SET_BYTES (bvec, SCM_C_BVEC_BITS2BYTES (bits)) | |
159 | ||
160 | #define SCM_C_BVEC_CLR_BYTES(bvec, bytes) (memset (bvec, 0, bytes)) | |
161 | #define SCM_C_BVEC_CLR_ALL_BITS(bvec, bits) SCM_C_BVEC_CLR_BYTES (bvec, SCM_C_BVEC_BITS2BYTES (bits)) | |
162 | ||
163 | /* testing and changing GC marks */ | |
164 | ||
165 | #define SCM_GCMARKP(x) SCM_GC_CELL_GET_BIT (x) | |
166 | #define SCM_SETGCMARK(x) SCM_GC_CELL_SET_BIT (x) | |
167 | #define SCM_CLRGCMARK(x) SCM_GC_CELL_CLR_BIT (x) | |
168 | ||
1fc8902f DH |
169 | |
170 | /* Low level cell data accessing macros. These macros should only be used | |
171 | * from within code related to garbage collection issues, since they will | |
172 | * never check the cells they are applied to - not even if guile is compiled | |
173 | * in debug mode. In particular these macros will even work for free cells, | |
174 | * which should never be encountered by user code. */ | |
175 | ||
176 | #define SCM_GC_CELL_WORD(x, n) \ | |
177 | (((const scm_t_bits *) SCM2PTR (x)) [n]) | |
178 | #define SCM_GC_CELL_OBJECT(x, n) \ | |
179 | (SCM_PACK (((const scm_t_bits *) SCM2PTR (x)) [n])) | |
180 | #define SCM_GC_SET_CELL_WORD(x, n, v) \ | |
181 | (((scm_t_bits *) SCM2PTR (x)) [n] = (scm_t_bits) (v)) | |
182 | #define SCM_GC_SET_CELL_OBJECT(x, n, v) \ | |
183 | (((scm_t_bits *) SCM2PTR (x)) [n] = SCM_UNPACK (v)) | |
184 | #define SCM_GC_CELL_TYPE(x) SCM_GC_CELL_WORD (x, 0) | |
185 | ||
186 | ||
187 | /* Except for the garbage collector, no part of guile should ever run over a | |
188 | * free cell. Thus, if guile is compiled in debug mode the SCM_CELL_* and | |
189 | * SCM_SET_CELL_* macros below report an error if they are applied to a free | |
190 | * cell. Some other plausibility checks are also performed. However, if | |
191 | * guile is not compiled in debug mode, there won't be any time penalty at all | |
192 | * when using these macros. */ | |
2549a709 | 193 | |
406c7d90 DH |
194 | #if (SCM_DEBUG_CELL_ACCESSES == 1) |
195 | # define SCM_VALIDATE_CELL(cell, expr) (scm_assert_cell_valid (cell), (expr)) | |
708cb87c | 196 | #else |
61045190 | 197 | # define SCM_VALIDATE_CELL(cell, expr) (expr) |
708cb87c | 198 | #endif |
46d53380 | 199 | |
f706a58b | 200 | #define SCM_CELL_WORD(x, n) \ |
1fc8902f | 201 | SCM_VALIDATE_CELL ((x), SCM_GC_CELL_WORD ((x), (n))) |
2549a709 DH |
202 | #define SCM_CELL_WORD_0(x) SCM_CELL_WORD (x, 0) |
203 | #define SCM_CELL_WORD_1(x) SCM_CELL_WORD (x, 1) | |
204 | #define SCM_CELL_WORD_2(x) SCM_CELL_WORD (x, 2) | |
205 | #define SCM_CELL_WORD_3(x) SCM_CELL_WORD (x, 3) | |
206 | ||
f706a58b | 207 | #define SCM_CELL_OBJECT(x, n) \ |
1fc8902f | 208 | SCM_VALIDATE_CELL ((x), SCM_GC_CELL_OBJECT ((x), (n))) |
2549a709 DH |
209 | #define SCM_CELL_OBJECT_0(x) SCM_CELL_OBJECT (x, 0) |
210 | #define SCM_CELL_OBJECT_1(x) SCM_CELL_OBJECT (x, 1) | |
211 | #define SCM_CELL_OBJECT_2(x) SCM_CELL_OBJECT (x, 2) | |
212 | #define SCM_CELL_OBJECT_3(x) SCM_CELL_OBJECT (x, 3) | |
213 | ||
f706a58b | 214 | #define SCM_SET_CELL_WORD(x, n, v) \ |
1fc8902f | 215 | SCM_VALIDATE_CELL ((x), SCM_GC_SET_CELL_WORD ((x), (n), (v))) |
2549a709 DH |
216 | #define SCM_SET_CELL_WORD_0(x, v) SCM_SET_CELL_WORD (x, 0, v) |
217 | #define SCM_SET_CELL_WORD_1(x, v) SCM_SET_CELL_WORD (x, 1, v) | |
218 | #define SCM_SET_CELL_WORD_2(x, v) SCM_SET_CELL_WORD (x, 2, v) | |
219 | #define SCM_SET_CELL_WORD_3(x, v) SCM_SET_CELL_WORD (x, 3, v) | |
220 | ||
f706a58b | 221 | #define SCM_SET_CELL_OBJECT(x, n, v) \ |
1fc8902f | 222 | SCM_VALIDATE_CELL ((x), SCM_GC_SET_CELL_OBJECT ((x), (n), (v))) |
2549a709 DH |
223 | #define SCM_SET_CELL_OBJECT_0(x, v) SCM_SET_CELL_OBJECT (x, 0, v) |
224 | #define SCM_SET_CELL_OBJECT_1(x, v) SCM_SET_CELL_OBJECT (x, 1, v) | |
225 | #define SCM_SET_CELL_OBJECT_2(x, v) SCM_SET_CELL_OBJECT (x, 2, v) | |
226 | #define SCM_SET_CELL_OBJECT_3(x, v) SCM_SET_CELL_OBJECT (x, 3, v) | |
227 | ||
228 | #define SCM_CELL_TYPE(x) SCM_CELL_WORD_0 (x) | |
229 | #define SCM_SET_CELL_TYPE(x, t) SCM_SET_CELL_WORD_0 (x, t) | |
230 | ||
61045190 | 231 | |
1fc8902f DH |
232 | /* Freelists consist of linked cells where the type entry holds the value |
233 | * scm_tc_free_cell and the second entry holds a pointer to the next cell of | |
234 | * the freelist. Due to this structure, freelist cells are not cons cells | |
235 | * and thus may not be accessed using SCM_CAR and SCM_CDR. */ | |
61045190 | 236 | |
1fc8902f DH |
237 | #define SCM_FREE_CELL_P(x) \ |
238 | (!SCM_IMP (x) && (SCM_GC_CELL_TYPE (x) == scm_tc_free_cell)) | |
239 | #define SCM_FREE_CELL_CDR(x) \ | |
240 | (SCM_GC_CELL_OBJECT ((x), 1)) | |
241 | #define SCM_SET_FREE_CELL_CDR(x, v) \ | |
242 | (SCM_GC_SET_CELL_OBJECT ((x), 1, (v))) | |
61045190 DH |
243 | |
244 | ||
92c2555f | 245 | #define SCM_CELL_WORD_LOC(x, n) ((scm_t_bits *) & SCM_CELL_WORD (x, n)) |
f706a58b DH |
246 | #define SCM_CARLOC(x) ((SCM *) SCM_CELL_WORD_LOC ((x), 0)) |
247 | #define SCM_CDRLOC(x) ((SCM *) SCM_CELL_WORD_LOC ((x), 1)) | |
2549a709 DH |
248 | |
249 | ||
6ba93e5e DH |
250 | /* SCM_PTR_LT and friends define how to compare two SCM_CELLPTRs (which may |
251 | * point to cells in different heap segments). | |
2549a709 | 252 | */ |
6ba93e5e DH |
253 | #define SCM_PTR_LT(x, y) ((x) < (y)) |
254 | #define SCM_PTR_GT(x, y) (SCM_PTR_LT (y, x)) | |
2549a709 DH |
255 | #define SCM_PTR_LE(x, y) (!SCM_PTR_GT (x, y)) |
256 | #define SCM_PTR_GE(x, y) (!SCM_PTR_LT (x, y)) | |
257 | ||
258 | ||
e618c9a3 | 259 | #define SCM_MARKEDP SCM_GCMARKP |
2d67e390 | 260 | #define SCM_NMARKEDP(x) (!SCM_MARKEDP (x)) |
79e3f9e2 | 261 | |
61045190 | 262 | #if (SCM_DEBUG_CELL_ACCESSES == 1) |
33b001fd | 263 | SCM_API unsigned int scm_debug_cell_accesses_p; |
61045190 DH |
264 | #endif |
265 | ||
33b001fd MV |
266 | SCM_API struct scm_t_heap_seg_data *scm_heap_table; |
267 | SCM_API size_t scm_n_heap_segs; | |
268 | SCM_API int scm_block_gc; | |
269 | SCM_API int scm_gc_heap_lock; | |
270 | SCM_API unsigned int scm_gc_running_p; | |
0f2d19dd JB |
271 | \f |
272 | ||
33b001fd MV |
273 | SCM_API size_t scm_default_init_heap_size_1; |
274 | SCM_API int scm_default_min_yield_1; | |
275 | SCM_API size_t scm_default_init_heap_size_2; | |
276 | SCM_API int scm_default_min_yield_2; | |
277 | SCM_API size_t scm_default_max_segment_size; | |
278 | ||
279 | SCM_API size_t scm_max_segment_size; | |
280 | SCM_API SCM_CELLPTR scm_heap_org; | |
281 | SCM_API SCM scm_freelist; | |
282 | SCM_API struct scm_t_freelist scm_master_freelist; | |
283 | SCM_API SCM scm_freelist2; | |
284 | SCM_API struct scm_t_freelist scm_master_freelist2; | |
285 | SCM_API unsigned long scm_gc_cells_collected; | |
286 | SCM_API unsigned long scm_gc_yield; | |
287 | SCM_API unsigned long scm_gc_malloc_collected; | |
288 | SCM_API unsigned long scm_gc_ports_collected; | |
289 | SCM_API unsigned long scm_cells_allocated; | |
290 | SCM_API unsigned long scm_mallocated; | |
291 | SCM_API unsigned long scm_mtrigger; | |
292 | ||
293 | SCM_API SCM scm_after_gc_hook; | |
294 | ||
295 | SCM_API scm_t_c_hook scm_before_gc_c_hook; | |
296 | SCM_API scm_t_c_hook scm_before_mark_c_hook; | |
297 | SCM_API scm_t_c_hook scm_before_sweep_c_hook; | |
298 | SCM_API scm_t_c_hook scm_after_sweep_c_hook; | |
299 | SCM_API scm_t_c_hook scm_after_gc_c_hook; | |
9b3e180c | 300 | |
bb2c57fa | 301 | #if defined (GUILE_DEBUG) || defined (GUILE_DEBUG_FREELIST) |
33b001fd MV |
302 | SCM_API SCM scm_map_free_list (void); |
303 | SCM_API SCM scm_free_list_length (void); | |
bb2c57fa MD |
304 | #endif |
305 | #ifdef GUILE_DEBUG_FREELIST | |
33b001fd | 306 | SCM_API SCM scm_gc_set_debug_check_freelist_x (SCM flag); |
88256b2e JB |
307 | #endif |
308 | ||
0f2d19dd | 309 | \f |
0f2d19dd | 310 | |
61045190 | 311 | #if (SCM_DEBUG_CELL_ACCESSES == 1) |
33b001fd MV |
312 | SCM_API void scm_assert_cell_valid (SCM); |
313 | SCM_API SCM scm_set_debug_cell_accesses_x (SCM flag); | |
61045190 | 314 | #endif |
33b001fd | 315 | SCM_API SCM scm_object_address (SCM obj); |
33b001fd MV |
316 | SCM_API SCM scm_gc_stats (void); |
317 | SCM_API SCM scm_gc (void); | |
318 | SCM_API void scm_gc_for_alloc (struct scm_t_freelist *freelist); | |
319 | SCM_API SCM scm_gc_for_newcell (struct scm_t_freelist *master, SCM *freelist); | |
4c48ba06 | 320 | #if 0 |
33b001fd | 321 | SCM_API void scm_alloc_cluster (struct scm_t_freelist *master); |
4c48ba06 | 322 | #endif |
33b001fd MV |
323 | SCM_API void scm_igc (const char *what); |
324 | SCM_API void scm_gc_mark (SCM p); | |
325 | SCM_API void scm_gc_mark_dependencies (SCM p); | |
326 | SCM_API void scm_mark_locations (SCM_STACKITEM x[], unsigned long n); | |
327 | SCM_API int scm_cellp (SCM value); | |
328 | SCM_API void scm_gc_sweep (void); | |
4c9419ac MV |
329 | |
330 | SCM_API void *scm_malloc (size_t size); | |
331 | SCM_API void *scm_realloc (void *mem, size_t size); | |
332 | SCM_API char *scm_strdup (const char *str); | |
333 | SCM_API char *scm_strndup (const char *str, size_t n); | |
334 | SCM_API void scm_gc_register_collectable_memory (void *mem, size_t size, | |
335 | const char *what); | |
336 | SCM_API void scm_gc_unregister_collectable_memory (void *mem, size_t size, | |
337 | const char *what); | |
338 | SCM_API void *scm_gc_malloc (size_t size, const char *what); | |
339 | SCM_API void *scm_gc_realloc (void *mem, size_t old_size, | |
340 | size_t new_size, const char *what); | |
341 | SCM_API void scm_gc_free (void *mem, size_t size, const char *what); | |
342 | SCM_API char *scm_gc_strdup (const char *str, const char *what); | |
343 | SCM_API char *scm_gc_strndup (const char *str, size_t n, const char *what); | |
344 | ||
33b001fd MV |
345 | SCM_API void scm_remember_upto_here_1 (SCM obj); |
346 | SCM_API void scm_remember_upto_here_2 (SCM obj1, SCM obj2); | |
347 | SCM_API void scm_remember_upto_here (SCM obj1, ...); | |
348 | SCM_API SCM scm_return_first (SCM elt, ...); | |
349 | SCM_API int scm_return_first_int (int x, ...); | |
350 | SCM_API SCM scm_permanent_object (SCM obj); | |
351 | SCM_API SCM scm_gc_protect_object (SCM obj); | |
352 | SCM_API SCM scm_gc_unprotect_object (SCM obj); | |
353 | SCM_API void scm_gc_register_root (SCM *p); | |
354 | SCM_API void scm_gc_unregister_root (SCM *p); | |
355 | SCM_API void scm_gc_register_roots (SCM *b, unsigned long n); | |
356 | SCM_API void scm_gc_unregister_roots (SCM *b, unsigned long n); | |
357 | SCM_API int scm_init_storage (void); | |
358 | SCM_API void *scm_get_stack_base (void); | |
359 | SCM_API void scm_init_gc (void); | |
d1ca2c64 | 360 | |
d678e25c MV |
361 | #if SCM_ENABLE_DEPRECATED == 1 |
362 | ||
363 | SCM_API SCM scm_deprecated_newcell (void); | |
364 | SCM_API SCM scm_deprecated_newcell2 (void); | |
365 | ||
366 | #define SCM_NEWCELL(_into) \ | |
367 | do { _into = scm_deprecated_newcell (); } while (0) | |
368 | #define SCM_NEWCELL2(_into) \ | |
369 | do { _into = scm_deprecated_newcell2 (); } while (0) | |
370 | ||
539b08a4 MV |
371 | SCM_API void * scm_must_malloc (size_t len, const char *what); |
372 | SCM_API void * scm_must_realloc (void *where, | |
373 | size_t olen, size_t len, | |
374 | const char *what); | |
375 | SCM_API char *scm_must_strdup (const char *str); | |
376 | SCM_API char *scm_must_strndup (const char *str, size_t n); | |
377 | SCM_API void scm_done_malloc (long size); | |
378 | SCM_API void scm_done_free (long size); | |
379 | SCM_API void scm_must_free (void *obj); | |
380 | ||
d678e25c MV |
381 | #endif |
382 | ||
61045190 | 383 | #endif /* SCM_GC_H */ |
89e00824 ML |
384 | |
385 | /* | |
386 | Local Variables: | |
387 | c-file-style: "gnu" | |
388 | End: | |
389 | */ |