summaryrefslogtreecommitdiff
path: root/src/lisp/ao_lisp_poly.c
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2016-11-11 21:07:09 -0800
committerKeith Packard <keithp@keithp.com>2017-02-20 11:16:50 -0800
commitd46ca67f93e9ecbc4d8c051c3fbdead85490b690 (patch)
tree3db7c362164b99c3c047eb213f12c7f9601971fd /src/lisp/ao_lisp_poly.c
parent00827a0ffe30938c26be216369fd2d8f8946d2c4 (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.c18
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;
+}