166 |
#define SCM_SETGCMARK(x) SCM_GC_CELL_SET_BIT (x) |
#define SCM_SETGCMARK(x) SCM_GC_CELL_SET_BIT (x) |
167 |
#define SCM_CLRGCMARK(x) SCM_GC_CELL_CLR_BIT (x) |
#define SCM_CLRGCMARK(x) SCM_GC_CELL_CLR_BIT (x) |
168 |
|
|
169 |
/* Low level cell data accessing macros: |
|
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. */ |
193 |
|
|
194 |
#if (SCM_DEBUG_CELL_ACCESSES == 1) |
#if (SCM_DEBUG_CELL_ACCESSES == 1) |
195 |
# define SCM_VALIDATE_CELL(cell, expr) (scm_assert_cell_valid (cell), (expr)) |
# define SCM_VALIDATE_CELL(cell, expr) (scm_assert_cell_valid (cell), (expr)) |
198 |
#endif |
#endif |
199 |
|
|
200 |
#define SCM_CELL_WORD(x, n) \ |
#define SCM_CELL_WORD(x, n) \ |
201 |
SCM_VALIDATE_CELL ((x), ((const scm_t_bits *) SCM2PTR (x)) [n]) |
SCM_VALIDATE_CELL ((x), SCM_GC_CELL_WORD ((x), (n))) |
202 |
#define SCM_CELL_WORD_0(x) SCM_CELL_WORD (x, 0) |
#define SCM_CELL_WORD_0(x) SCM_CELL_WORD (x, 0) |
203 |
#define SCM_CELL_WORD_1(x) SCM_CELL_WORD (x, 1) |
#define SCM_CELL_WORD_1(x) SCM_CELL_WORD (x, 1) |
204 |
#define SCM_CELL_WORD_2(x) SCM_CELL_WORD (x, 2) |
#define SCM_CELL_WORD_2(x) SCM_CELL_WORD (x, 2) |
205 |
#define SCM_CELL_WORD_3(x) SCM_CELL_WORD (x, 3) |
#define SCM_CELL_WORD_3(x) SCM_CELL_WORD (x, 3) |
206 |
|
|
207 |
#define SCM_CELL_OBJECT(x, n) \ |
#define SCM_CELL_OBJECT(x, n) \ |
208 |
SCM_VALIDATE_CELL ((x), SCM_PACK (((const scm_t_bits *) SCM2PTR (x)) [n])) |
SCM_VALIDATE_CELL ((x), SCM_GC_CELL_OBJECT ((x), (n))) |
209 |
#define SCM_CELL_OBJECT_0(x) SCM_CELL_OBJECT (x, 0) |
#define SCM_CELL_OBJECT_0(x) SCM_CELL_OBJECT (x, 0) |
210 |
#define SCM_CELL_OBJECT_1(x) SCM_CELL_OBJECT (x, 1) |
#define SCM_CELL_OBJECT_1(x) SCM_CELL_OBJECT (x, 1) |
211 |
#define SCM_CELL_OBJECT_2(x) SCM_CELL_OBJECT (x, 2) |
#define SCM_CELL_OBJECT_2(x) SCM_CELL_OBJECT (x, 2) |
212 |
#define SCM_CELL_OBJECT_3(x) SCM_CELL_OBJECT (x, 3) |
#define SCM_CELL_OBJECT_3(x) SCM_CELL_OBJECT (x, 3) |
213 |
|
|
214 |
#define SCM_SET_CELL_WORD(x, n, v) \ |
#define SCM_SET_CELL_WORD(x, n, v) \ |
215 |
SCM_VALIDATE_CELL ((x), ((scm_t_bits *) SCM2PTR (x)) [n] = (scm_t_bits) (v)) |
SCM_VALIDATE_CELL ((x), SCM_GC_SET_CELL_WORD ((x), (n), (v))) |
216 |
#define SCM_SET_CELL_WORD_0(x, v) SCM_SET_CELL_WORD (x, 0, v) |
#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) |
#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) |
#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) |
#define SCM_SET_CELL_WORD_3(x, v) SCM_SET_CELL_WORD (x, 3, v) |
220 |
|
|
221 |
#define SCM_SET_CELL_OBJECT(x, n, v) \ |
#define SCM_SET_CELL_OBJECT(x, n, v) \ |
222 |
SCM_VALIDATE_CELL ((x), ((scm_t_bits *) SCM2PTR (x)) [n] = SCM_UNPACK (v)) |
SCM_VALIDATE_CELL ((x), SCM_GC_SET_CELL_OBJECT ((x), (n), (v))) |
223 |
#define SCM_SET_CELL_OBJECT_0(x, v) SCM_SET_CELL_OBJECT (x, 0, v) |
#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) |
#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) |
#define SCM_SET_CELL_OBJECT_2(x, v) SCM_SET_CELL_OBJECT (x, 2, v) |
229 |
#define SCM_SET_CELL_TYPE(x, t) SCM_SET_CELL_WORD_0 (x, t) |
#define SCM_SET_CELL_TYPE(x, t) SCM_SET_CELL_WORD_0 (x, t) |
230 |
|
|
231 |
|
|
232 |
/* Except for the garbage collector, no part of guile should ever run over a |
/* Freelists consist of linked cells where the type entry holds the value |
233 |
* free cell. Thus, in debug mode the above macros report an error if they |
* scm_tc_free_cell and the second entry holds a pointer to the next cell of |
234 |
* are applied to a free cell. Since the garbage collector is allowed to |
* the freelist. Due to this structure, freelist cells are not cons cells |
235 |
* access free cells, it needs its own way to access cells which will not |
* and thus may not be accessed using SCM_CAR and SCM_CDR. */ |
|
* result in errors when in debug mode. */ |
|
236 |
|
|
237 |
#define SCM_GC_CELL_TYPE(x) \ |
#define SCM_FREE_CELL_P(x) \ |
238 |
(((const scm_t_bits *) SCM2PTR (x)) [0]) |
(!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))) |
243 |
|
|
244 |
|
|
245 |
#define SCM_CELL_WORD_LOC(x, n) ((scm_t_bits *) & SCM_CELL_WORD (x, n)) |
#define SCM_CELL_WORD_LOC(x, n) ((scm_t_bits *) & SCM_CELL_WORD (x, n)) |
256 |
#define SCM_PTR_GE(x, y) (!SCM_PTR_LT (x, y)) |
#define SCM_PTR_GE(x, y) (!SCM_PTR_LT (x, y)) |
257 |
|
|
258 |
|
|
|
/* Freelists consist of linked cells where the type entry holds the value |
|
|
* scm_tc_free_cell and the second entry holds a pointer to the next cell of |
|
|
* the freelist. Due to this structure, freelist cells are not cons cells |
|
|
* and thus may not be accessed using SCM_CAR and SCM_CDR. |
|
|
*/ |
|
|
|
|
|
#define SCM_FREE_CELL_P(x) \ |
|
|
(!SCM_IMP (x) && (* (const scm_t_bits *) SCM2PTR (x) == scm_tc_free_cell)) |
|
|
#define SCM_FREE_CELL_CDR(x) \ |
|
|
(SCM_PACK (((const scm_t_bits *) SCM2PTR (x)) [1])) |
|
|
#define SCM_SET_FREE_CELL_CDR(x, v) \ |
|
|
(((scm_t_bits *) SCM2PTR (x)) [1] = SCM_UNPACK (v)) |
|
|
|
|
|
|
|
259 |
#define SCM_MARKEDP SCM_GCMARKP |
#define SCM_MARKEDP SCM_GCMARKP |
260 |
#define SCM_NMARKEDP(x) (!SCM_MARKEDP (x)) |
#define SCM_NMARKEDP(x) (!SCM_MARKEDP (x)) |
261 |
|
|