diff options
| -rw-r--r-- | src/scheme/ao_scheme.h | 13 | ||||
| -rw-r--r-- | src/scheme/ao_scheme_frame.c | 5 | ||||
| -rw-r--r-- | src/scheme/ao_scheme_mem.c | 18 | ||||
| -rw-r--r-- | src/scheme/ao_scheme_poly.c | 2 | 
4 files changed, 21 insertions, 17 deletions
| diff --git a/src/scheme/ao_scheme.h b/src/scheme/ao_scheme.h index b8e683fb..5cae0bda 100644 --- a/src/scheme/ao_scheme.h +++ b/src/scheme/ao_scheme.h @@ -155,8 +155,17 @@ ao_scheme_is_const(ao_poly poly) {  	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); diff --git a/src/scheme/ao_scheme_frame.c b/src/scheme/ao_scheme_frame.c index 46f941e6..a7e5153f 100644 --- a/src/scheme/ao_scheme_frame.c +++ b/src/scheme/ao_scheme_frame.c @@ -86,8 +86,6 @@ frame_mark(void *addr)  		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); @@ -110,9 +108,6 @@ frame_move(void *addr)  		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); diff --git a/src/scheme/ao_scheme_mem.c b/src/scheme/ao_scheme_mem.c index a336fdfe..55872b62 100644 --- a/src/scheme/ao_scheme_mem.c +++ b/src/scheme/ao_scheme_mem.c @@ -313,7 +313,7 @@ static struct ao_scheme_chunk ao_scheme_chunk[AO_SCHEME_NCHUNK];  /* 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; @@ -723,7 +723,7 @@ ao_scheme_cons_check(struct ao_scheme_cons *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)) { @@ -752,7 +752,7 @@ int  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); @@ -804,7 +804,7 @@ ao_scheme_poly_mark(ao_poly p, uint8_t do_note_cons)  		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) { @@ -864,7 +864,7 @@ ao_scheme_move_memory(const struct ao_scheme_type *type, void **ref)  	void		*addr = *ref;  	uint16_t	offset, orig_offset; -	if (!AO_SCHEME_IS_POOL(addr)) +	if (!ao_scheme_is_pool_addr(addr))  		return 1;  	(void) type; @@ -874,7 +874,7 @@ ao_scheme_move_memory(const struct ao_scheme_type *type, void **ref)  	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;  	} @@ -914,7 +914,7 @@ ao_scheme_poly_move(ao_poly *ref, uint8_t do_note_cons)  		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); @@ -1060,7 +1060,7 @@ ao_scheme_print_mark_addr(void *addr)  		ao_scheme_abort();  #endif -	if (!AO_SCHEME_IS_POOL(addr)) +	if (!ao_scheme_is_pool_addr(addr))  		return 0;  	if (!ao_scheme_print_cleared) { @@ -1084,7 +1084,7 @@ ao_scheme_print_clear_addr(void *addr)  		ao_scheme_abort();  #endif -	if (!AO_SCHEME_IS_POOL(addr)) +	if (!ao_scheme_is_pool_addr(addr))  		return;  	if (!ao_scheme_print_cleared) diff --git a/src/scheme/ao_scheme_poly.c b/src/scheme/ao_scheme_poly.c index 25ac6d67..0cffc196 100644 --- a/src/scheme/ao_scheme_poly.c +++ b/src/scheme/ao_scheme_poly.c @@ -65,7 +65,7 @@ ao_scheme_poly(const void *addr, ao_poly type) {  	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;  } | 
