diff options
author | Keith Packard <keithp@keithp.com> | 2017-12-19 12:16:24 -0800 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2017-12-19 12:16:24 -0800 |
commit | 71fb79492cb955af4bd52e79f1fa69d17e084dbc (patch) | |
tree | 098c8506f476dd61a18bd078fb247a90dabc5a6b /src/scheme/ao_scheme.h | |
parent | 34f998d147d08e966daad1ab76c40906018d3d8d (diff) |
altos/scheme: Replace memory pool macros with inlines
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>
Diffstat (limited to 'src/scheme/ao_scheme.h')
-rw-r--r-- | src/scheme/ao_scheme.h | 13 |
1 files changed, 11 insertions, 2 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); |