AO_SCHEME_IS_CONST -> ao_scheme_is_const_addr
AO_SCHEME_IS_POOL -> ao_scheme_is_pool_addr
Provides better typechecking and avoids confusion with
ao_scheme_is_const inline (which takes an ao_poly instead of a void *)
Signed-off-by: Keith Packard <keithp@keithp.com>
return poly & AO_SCHEME_CONST;
}
return poly & AO_SCHEME_CONST;
}
-#define AO_SCHEME_IS_CONST(a) (ao_scheme_const <= ((uint8_t *) (a)) && ((uint8_t *) (a)) < ao_scheme_const + AO_SCHEME_POOL_CONST)
-#define AO_SCHEME_IS_POOL(a) (ao_scheme_pool <= ((uint8_t *) (a)) && ((uint8_t *) (a)) < ao_scheme_pool + AO_SCHEME_POOL)
+static inline int
+ao_scheme_is_const_addr(const void *addr) {
+ const uint8_t *a = addr;
+ return (ao_scheme_const <= a) && (a < ao_scheme_const + AO_SCHEME_POOL_CONST);
+}
+
+static inline int
+ao_scheme_is_pool_addr(const void *addr) {
+ const uint8_t *a = addr;
+ return (ao_scheme_pool <= a) && (a < ao_scheme_pool + AO_SCHEME_POOL);
+}
void *
ao_scheme_ref(ao_poly poly);
void *
ao_scheme_ref(ao_poly poly);
struct ao_scheme_frame_vals *vals = ao_scheme_poly_frame_vals(frame->vals);
MDBG_MOVE("frame mark %d\n", MDBG_OFFSET(frame));
struct ao_scheme_frame_vals *vals = ao_scheme_poly_frame_vals(frame->vals);
MDBG_MOVE("frame mark %d\n", MDBG_OFFSET(frame));
- if (!AO_SCHEME_IS_POOL(frame))
- break;
if (!ao_scheme_mark_memory(&ao_scheme_frame_vals_type, vals))
frame_vals_mark(vals);
frame = ao_scheme_poly_frame(frame->prev);
if (!ao_scheme_mark_memory(&ao_scheme_frame_vals_type, vals))
frame_vals_mark(vals);
frame = ao_scheme_poly_frame(frame->prev);
int ret;
MDBG_MOVE("frame move %d\n", MDBG_OFFSET(frame));
int ret;
MDBG_MOVE("frame move %d\n", MDBG_OFFSET(frame));
- if (!AO_SCHEME_IS_POOL(frame))
- break;
-
vals = ao_scheme_poly_frame_vals(frame->vals);
if (!ao_scheme_move_memory(&ao_scheme_frame_vals_type, (void **) &vals))
frame_vals_move(vals);
vals = ao_scheme_poly_frame_vals(frame->vals);
if (!ao_scheme_move_memory(&ao_scheme_frame_vals_type, (void **) &vals))
frame_vals_move(vals);
/* Offset of an address within the pool. */
static inline uint16_t pool_offset(void *addr) {
#if DBG_MEM
/* Offset of an address within the pool. */
static inline uint16_t pool_offset(void *addr) {
#if DBG_MEM
- if (!AO_SCHEME_IS_POOL(addr))
+ if (!ao_scheme_is_pool_addr(addr))
ao_scheme_abort();
#endif
return ((uint8_t *) addr) - ao_scheme_pool;
ao_scheme_abort();
#endif
return ((uint8_t *) addr) - ao_scheme_pool;
reset_chunks();
walk(ao_scheme_mark_ref, ao_scheme_poly_mark_ref);
while (cons) {
reset_chunks();
walk(ao_scheme_mark_ref, ao_scheme_poly_mark_ref);
while (cons) {
- if (!AO_SCHEME_IS_POOL(cons))
+ if (!ao_scheme_is_pool_addr(cons))
break;
offset = pool_offset(cons);
if (busy(ao_scheme_busy, offset)) {
break;
offset = pool_offset(cons);
if (busy(ao_scheme_busy, offset)) {
ao_scheme_mark_memory(const struct ao_scheme_type *type, void *addr)
{
int offset;
ao_scheme_mark_memory(const struct ao_scheme_type *type, void *addr)
{
int offset;
- if (!AO_SCHEME_IS_POOL(addr))
+ if (!ao_scheme_is_pool_addr(addr))
return 1;
offset = pool_offset(addr);
return 1;
offset = pool_offset(addr);
return 1;
addr = ao_scheme_ref(p);
return 1;
addr = ao_scheme_ref(p);
- if (!AO_SCHEME_IS_POOL(addr))
+ if (!ao_scheme_is_pool_addr(addr))
return 1;
if (type == AO_SCHEME_CONS && do_note_cons) {
return 1;
if (type == AO_SCHEME_CONS && do_note_cons) {
void *addr = *ref;
uint16_t offset, orig_offset;
void *addr = *ref;
uint16_t offset, orig_offset;
- if (!AO_SCHEME_IS_POOL(addr))
+ if (!ao_scheme_is_pool_addr(addr))
offset = move_map(orig_offset);
if (offset != orig_offset) {
MDBG_MOVE("update ref %d %d -> %d\n",
offset = move_map(orig_offset);
if (offset != orig_offset) {
MDBG_MOVE("update ref %d %d -> %d\n",
- AO_SCHEME_IS_POOL(ref) ? MDBG_OFFSET(ref) : -1,
+ ao_scheme_is_pool_addr(ref) ? MDBG_OFFSET(ref) : -1,
orig_offset, offset);
*ref = ao_scheme_pool + offset;
}
orig_offset, offset);
*ref = ao_scheme_pool + offset;
}
return 1;
addr = ao_scheme_ref(p);
return 1;
addr = ao_scheme_ref(p);
- if (!AO_SCHEME_IS_POOL(addr))
+ if (!ao_scheme_is_pool_addr(addr))
return 1;
orig_offset = pool_offset(addr);
return 1;
orig_offset = pool_offset(addr);
ao_scheme_abort();
#endif
ao_scheme_abort();
#endif
- if (!AO_SCHEME_IS_POOL(addr))
+ if (!ao_scheme_is_pool_addr(addr))
return 0;
if (!ao_scheme_print_cleared) {
return 0;
if (!ao_scheme_print_cleared) {
ao_scheme_abort();
#endif
ao_scheme_abort();
#endif
- if (!AO_SCHEME_IS_POOL(addr))
+ if (!ao_scheme_is_pool_addr(addr))
return;
if (!ao_scheme_print_cleared)
return;
if (!ao_scheme_print_cleared)
const uint8_t *a = addr;
if (a == NULL)
return AO_SCHEME_NIL;
const uint8_t *a = addr;
if (a == NULL)
return AO_SCHEME_NIL;
- if (AO_SCHEME_IS_CONST(a))
+ if (ao_scheme_is_const_addr(a))
return AO_SCHEME_CONST | (a - ao_scheme_const + 4) | type;
return (a - ao_scheme_pool + 4) | type;
}
return AO_SCHEME_CONST | (a - ao_scheme_const + 4) | type;
return (a - ao_scheme_pool + 4) | type;
}