diff options
author | Keith Packard <keithp@keithp.com> | 2016-11-11 21:07:09 -0800 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2016-11-17 22:18:39 -0800 |
commit | 7b99963e13f1cf3136c67521c851827377790a06 (patch) | |
tree | e55fb0a77288daa9d296621b7c29ce799f8e71e8 /src/lisp/ao_lisp_poly.c | |
parent | 426f172d92cdef177150f990c4f52b0223a5f6f7 (diff) |
altos/lisp: Make ao_lisp_ref and ao_lisp_poly non-inline
These functions are pretty large and end up consuming quite a bit of
space if inlined everywhere they are used.
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src/lisp/ao_lisp_poly.c')
-rw-r--r-- | src/lisp/ao_lisp_poly.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/lisp/ao_lisp_poly.c b/src/lisp/ao_lisp_poly.c index bfd75ae3..9717fd73 100644 --- a/src/lisp/ao_lisp_poly.c +++ b/src/lisp/ao_lisp_poly.c @@ -84,3 +84,21 @@ ao_lisp_poly_patom(ao_poly p) f->patom(p); } +void * +ao_lisp_ref(ao_poly poly) { + if (poly == AO_LISP_NIL) + return NULL; + if (poly & AO_LISP_CONST) + return (void *) (AO_LISP_CONST_BASE + (poly & AO_LISP_REF_MASK)); + return (void *) (AO_LISP_POOL_BASE + (poly & AO_LISP_REF_MASK)); +} + +ao_poly +ao_lisp_poly(const void *addr, ao_poly type) { + const uint8_t *a = addr; + if (a == NULL) + return AO_LISP_NIL; + if (AO_LISP_IS_CONST(a)) + return AO_LISP_CONST | (a - AO_LISP_CONST_BASE) | type; + return (a - AO_LISP_POOL_BASE) | type; +} |