2 * Copyright © 2016 Keith Packard <keithp@keithp.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
21 #define DBG_FREE_CONS 0
26 #include <ao_lisp_os.h>
31 typedef uint16_t ao_poly;
32 typedef int16_t ao_signed_poly;
36 struct ao_lisp_os_save {
39 uint16_t const_checksum;
40 uint16_t const_checksum_inv;
43 #define AO_LISP_POOL_EXTRA (sizeof(struct ao_lisp_os_save))
44 #define AO_LISP_POOL ((int) (AO_LISP_POOL_TOTAL - AO_LISP_POOL_EXTRA))
47 ao_lisp_os_save(void);
50 ao_lisp_os_restore_save(struct ao_lisp_os_save *save, int offset);
53 ao_lisp_os_restore(void);
57 #ifdef AO_LISP_MAKE_CONST
58 #define AO_LISP_POOL_CONST 16384
59 extern uint8_t ao_lisp_const[AO_LISP_POOL_CONST] __attribute__((aligned(4)));
60 #define ao_lisp_pool ao_lisp_const
61 #define AO_LISP_POOL AO_LISP_POOL_CONST
63 #define _atom(n) ao_lisp_atom_poly(ao_lisp_atom_intern(n))
64 #define _bool(v) ao_lisp_bool_poly(ao_lisp_bool_get(v))
66 #define _ao_lisp_bool_true _bool(1)
67 #define _ao_lisp_bool_false _bool(0)
69 #define _ao_lisp_atom_eof _atom("eof")
70 #define _ao_lisp_atom_else _atom("else")
72 #define AO_LISP_BUILTIN_ATOMS
73 #include "ao_lisp_builtin.h"
76 #include "ao_lisp_const.h"
78 #define AO_LISP_POOL 3072
80 extern uint8_t ao_lisp_pool[AO_LISP_POOL + AO_LISP_POOL_EXTRA] __attribute__((aligned(4)));
84 #define AO_LISP_CONS 0
86 #define AO_LISP_STRING 2
87 #define AO_LISP_OTHER 3
89 #define AO_LISP_TYPE_MASK 0x0003
90 #define AO_LISP_TYPE_SHIFT 2
91 #define AO_LISP_REF_MASK 0x7ffc
92 #define AO_LISP_CONST 0x8000
94 /* These have a type value at the start of the struct */
95 #define AO_LISP_ATOM 4
96 #define AO_LISP_BUILTIN 5
97 #define AO_LISP_FRAME 6
98 #define AO_LISP_FRAME_VALS 7
99 #define AO_LISP_LAMBDA 8
100 #define AO_LISP_STACK 9
101 #define AO_LISP_BOOL 10
102 #define AO_LISP_BIGINT 11
103 #define AO_LISP_FLOAT 12
104 #define AO_LISP_NUM_TYPE 13
106 /* Leave two bits for types to use as they please */
107 #define AO_LISP_OTHER_TYPE_MASK 0x3f
109 #define AO_LISP_NIL 0
111 extern uint16_t ao_lisp_top;
113 #define AO_LISP_OOM 0x01
114 #define AO_LISP_DIVIDE_BY_ZERO 0x02
115 #define AO_LISP_INVALID 0x04
116 #define AO_LISP_UNDEFINED 0x08
117 #define AO_LISP_REDEFINED 0x10
118 #define AO_LISP_EOF 0x20
119 #define AO_LISP_EXIT 0x40
121 extern uint8_t ao_lisp_exception;
124 ao_lisp_is_const(ao_poly poly) {
125 return poly & AO_LISP_CONST;
128 #define AO_LISP_IS_CONST(a) (ao_lisp_const <= ((uint8_t *) (a)) && ((uint8_t *) (a)) < ao_lisp_const + AO_LISP_POOL_CONST)
129 #define AO_LISP_IS_POOL(a) (ao_lisp_pool <= ((uint8_t *) (a)) && ((uint8_t *) (a)) < ao_lisp_pool + AO_LISP_POOL)
130 #define AO_LISP_IS_INT(p) (ao_lisp_poly_base_type(p) == AO_LISP_INT)
133 ao_lisp_ref(ao_poly poly);
136 ao_lisp_poly(const void *addr, ao_poly type);
138 struct ao_lisp_type {
139 int (*size)(void *addr);
140 void (*mark)(void *addr);
141 void (*move)(void *addr);
145 struct ao_lisp_cons {
150 struct ao_lisp_atom {
162 struct ao_lisp_frame_vals {
165 struct ao_lisp_val vals[];
168 struct ao_lisp_frame {
175 struct ao_lisp_bool {
181 struct ao_lisp_bigint {
185 struct ao_lisp_float {
192 #if __BYTE_ORDER == __LITTLE_ENDIAN
193 static inline uint32_t
194 ao_lisp_int_bigint(int32_t i) {
195 return AO_LISP_BIGINT | (i << 8);
197 static inline int32_t
198 ao_lisp_bigint_int(uint32_t bi) {
199 return (int32_t) bi >> 8;
202 static inline uint32_t
203 ao_lisp_int_bigint(int32_t i) {
204 return (uint32_t) (i & 0xffffff) | (AO_LISP_BIGINT << 24);
206 static inlint int32_t
207 ao_lisp_bigint_int(uint32_t bi) {
208 return (int32_t) (bi << 8) >> 8;
212 #define AO_LISP_MIN_INT (-(1 << (15 - AO_LISP_TYPE_SHIFT)))
213 #define AO_LISP_MAX_INT ((1 << (15 - AO_LISP_TYPE_SHIFT)) - 1)
214 #define AO_LISP_MIN_BIGINT (-(1 << 24))
215 #define AO_LISP_MAX_BIGINT ((1 << 24) - 1)
217 #define AO_LISP_NOT_INTEGER 0x7fffffff
219 /* Set on type when the frame escapes the lambda */
220 #define AO_LISP_FRAME_MARK 0x80
221 #define AO_LISP_FRAME_PRINT 0x40
223 static inline int ao_lisp_frame_marked(struct ao_lisp_frame *f) {
224 return f->type & AO_LISP_FRAME_MARK;
227 static inline struct ao_lisp_frame *
228 ao_lisp_poly_frame(ao_poly poly) {
229 return ao_lisp_ref(poly);
232 static inline ao_poly
233 ao_lisp_frame_poly(struct ao_lisp_frame *frame) {
234 return ao_lisp_poly(frame, AO_LISP_OTHER);
237 static inline struct ao_lisp_frame_vals *
238 ao_lisp_poly_frame_vals(ao_poly poly) {
239 return ao_lisp_ref(poly);
242 static inline ao_poly
243 ao_lisp_frame_vals_poly(struct ao_lisp_frame_vals *vals) {
244 return ao_lisp_poly(vals, AO_LISP_OTHER);
248 eval_sexpr, /* Evaluate an sexpr */
249 eval_val, /* Value computed */
250 eval_formal, /* Formal computed */
251 eval_exec, /* Start a lambda evaluation */
252 eval_apply, /* Execute apply */
253 eval_cond, /* Start next cond clause */
254 eval_cond_test, /* Check cond condition */
255 eval_begin, /* Start next begin entry */
256 eval_while, /* Start while condition */
257 eval_while_test, /* Check while condition */
258 eval_macro, /* Finished with macro generation */
261 struct ao_lisp_stack {
262 uint8_t type; /* AO_LISP_STACK */
263 uint8_t state; /* enum eval_state */
264 ao_poly prev; /* previous stack frame */
265 ao_poly sexprs; /* expressions to evaluate */
266 ao_poly values; /* values computed */
267 ao_poly values_tail; /* end of the values list for easy appending */
268 ao_poly frame; /* current lookup frame */
269 ao_poly list; /* most recent function call */
272 #define AO_LISP_STACK_MARK 0x80 /* set on type when a reference has been taken */
273 #define AO_LISP_STACK_PRINT 0x40 /* stack is being printed */
275 static inline int ao_lisp_stack_marked(struct ao_lisp_stack *s) {
276 return s->type & AO_LISP_STACK_MARK;
279 static inline void ao_lisp_stack_mark(struct ao_lisp_stack *s) {
280 s->type |= AO_LISP_STACK_MARK;
283 static inline struct ao_lisp_stack *
284 ao_lisp_poly_stack(ao_poly p)
286 return ao_lisp_ref(p);
289 static inline ao_poly
290 ao_lisp_stack_poly(struct ao_lisp_stack *stack)
292 return ao_lisp_poly(stack, AO_LISP_OTHER);
295 extern ao_poly ao_lisp_v;
297 #define AO_LISP_FUNC_LAMBDA 0
298 #define AO_LISP_FUNC_NLAMBDA 1
299 #define AO_LISP_FUNC_MACRO 2
300 #define AO_LISP_FUNC_LEXPR 3
302 #define AO_LISP_FUNC_FREE_ARGS 0x80
303 #define AO_LISP_FUNC_MASK 0x7f
305 #define AO_LISP_FUNC_F_LAMBDA (AO_LISP_FUNC_FREE_ARGS | AO_LISP_FUNC_LAMBDA)
306 #define AO_LISP_FUNC_F_NLAMBDA (AO_LISP_FUNC_FREE_ARGS | AO_LISP_FUNC_NLAMBDA)
307 #define AO_LISP_FUNC_F_MACRO (AO_LISP_FUNC_FREE_ARGS | AO_LISP_FUNC_MACRO)
308 #define AO_LISP_FUNC_F_LEXPR (AO_LISP_FUNC_FREE_ARGS | AO_LISP_FUNC_LEXPR)
310 struct ao_lisp_builtin {
316 #define AO_LISP_BUILTIN_ID
317 #include "ao_lisp_builtin.h"
319 typedef ao_poly (*ao_lisp_func_t)(struct ao_lisp_cons *cons);
321 extern const ao_lisp_func_t ao_lisp_builtins[];
323 static inline ao_lisp_func_t
324 ao_lisp_func(struct ao_lisp_builtin *b)
326 return ao_lisp_builtins[b->func];
329 struct ao_lisp_lambda {
336 static inline struct ao_lisp_lambda *
337 ao_lisp_poly_lambda(ao_poly poly)
339 return ao_lisp_ref(poly);
342 static inline ao_poly
343 ao_lisp_lambda_poly(struct ao_lisp_lambda *lambda)
345 return ao_lisp_poly(lambda, AO_LISP_OTHER);
349 ao_lisp_poly_other(ao_poly poly) {
350 return ao_lisp_ref(poly);
353 static inline uint8_t
354 ao_lisp_other_type(void *other) {
356 if ((*((uint8_t *) other) & AO_LISP_OTHER_TYPE_MASK) >= AO_LISP_NUM_TYPE)
359 return *((uint8_t *) other) & AO_LISP_OTHER_TYPE_MASK;
362 static inline ao_poly
363 ao_lisp_other_poly(const void *other)
365 return ao_lisp_poly(other, AO_LISP_OTHER);
369 ao_lisp_size_round(int size)
371 return (size + 3) & ~3;
375 ao_lisp_size(const struct ao_lisp_type *type, void *addr)
377 return ao_lisp_size_round(type->size(addr));
380 #define AO_LISP_OTHER_POLY(other) ((ao_poly)(other) + AO_LISP_OTHER)
382 static inline int ao_lisp_poly_base_type(ao_poly poly) {
383 return poly & AO_LISP_TYPE_MASK;
386 static inline int ao_lisp_poly_type(ao_poly poly) {
387 int type = poly & AO_LISP_TYPE_MASK;
388 if (type == AO_LISP_OTHER)
389 return ao_lisp_other_type(ao_lisp_poly_other(poly));
394 ao_lisp_is_cons(ao_poly poly) {
395 return (ao_lisp_poly_base_type(poly) == AO_LISP_CONS);
399 ao_lisp_is_pair(ao_poly poly) {
400 return poly != AO_LISP_NIL && (ao_lisp_poly_base_type(poly) == AO_LISP_CONS);
403 static inline struct ao_lisp_cons *
404 ao_lisp_poly_cons(ao_poly poly)
406 return ao_lisp_ref(poly);
409 static inline ao_poly
410 ao_lisp_cons_poly(struct ao_lisp_cons *cons)
412 return ao_lisp_poly(cons, AO_LISP_CONS);
415 static inline int32_t
416 ao_lisp_poly_int(ao_poly poly)
418 return (int32_t) ((ao_signed_poly) poly >> AO_LISP_TYPE_SHIFT);
421 static inline ao_poly
422 ao_lisp_int_poly(int32_t i)
424 return ((ao_poly) i << 2) | AO_LISP_INT;
427 static inline struct ao_lisp_bigint *
428 ao_lisp_poly_bigint(ao_poly poly)
430 return ao_lisp_ref(poly);
433 static inline ao_poly
434 ao_lisp_bigint_poly(struct ao_lisp_bigint *bi)
436 return ao_lisp_poly(bi, AO_LISP_OTHER);
440 ao_lisp_poly_string(ao_poly poly)
442 return ao_lisp_ref(poly);
445 static inline ao_poly
446 ao_lisp_string_poly(char *s)
448 return ao_lisp_poly(s, AO_LISP_STRING);
451 static inline struct ao_lisp_atom *
452 ao_lisp_poly_atom(ao_poly poly)
454 return ao_lisp_ref(poly);
457 static inline ao_poly
458 ao_lisp_atom_poly(struct ao_lisp_atom *a)
460 return ao_lisp_poly(a, AO_LISP_OTHER);
463 static inline struct ao_lisp_builtin *
464 ao_lisp_poly_builtin(ao_poly poly)
466 return ao_lisp_ref(poly);
469 static inline ao_poly
470 ao_lisp_builtin_poly(struct ao_lisp_builtin *b)
472 return ao_lisp_poly(b, AO_LISP_OTHER);
475 static inline ao_poly
476 ao_lisp_bool_poly(struct ao_lisp_bool *b)
478 return ao_lisp_poly(b, AO_LISP_OTHER);
481 static inline struct ao_lisp_bool *
482 ao_lisp_poly_bool(ao_poly poly)
484 return ao_lisp_ref(poly);
487 static inline ao_poly
488 ao_lisp_float_poly(struct ao_lisp_float *f)
490 return ao_lisp_poly(f, AO_LISP_OTHER);
493 static inline struct ao_lisp_float *
494 ao_lisp_poly_float(ao_poly poly)
496 return ao_lisp_ref(poly);
500 ao_lisp_poly_number(ao_poly p);
502 /* memory functions */
504 extern int ao_lisp_collects[2];
505 extern int ao_lisp_freed[2];
506 extern int ao_lisp_loops[2];
508 /* returns 1 if the object was already marked */
510 ao_lisp_mark(const struct ao_lisp_type *type, void *addr);
512 /* returns 1 if the object was already marked */
514 ao_lisp_mark_memory(const struct ao_lisp_type *type, void *addr);
517 ao_lisp_move_map(void *addr);
519 /* returns 1 if the object was already moved */
521 ao_lisp_move(const struct ao_lisp_type *type, void **ref);
523 /* returns 1 if the object was already moved */
525 ao_lisp_move_memory(const struct ao_lisp_type *type, void **ref);
528 ao_lisp_alloc(int size);
530 #define AO_LISP_COLLECT_FULL 1
531 #define AO_LISP_COLLECT_INCREMENTAL 0
534 ao_lisp_collect(uint8_t style);
538 ao_lisp_cons_check(struct ao_lisp_cons *cons);
542 ao_lisp_cons_stash(int id, struct ao_lisp_cons *cons);
544 struct ao_lisp_cons *
545 ao_lisp_cons_fetch(int id);
548 ao_lisp_poly_stash(int id, ao_poly poly);
551 ao_lisp_poly_fetch(int id);
554 ao_lisp_string_stash(int id, char *string);
557 ao_lisp_string_fetch(int id);
560 ao_lisp_stack_stash(int id, struct ao_lisp_stack *stack) {
561 ao_lisp_poly_stash(id, ao_lisp_stack_poly(stack));
564 static inline struct ao_lisp_stack *
565 ao_lisp_stack_fetch(int id) {
566 return ao_lisp_poly_stack(ao_lisp_poly_fetch(id));
570 ao_lisp_frame_stash(int id, struct ao_lisp_frame *frame);
572 struct ao_lisp_frame *
573 ao_lisp_frame_fetch(int id);
577 extern const struct ao_lisp_type ao_lisp_bool_type;
580 ao_lisp_bool_write(ao_poly v);
582 #ifdef AO_LISP_MAKE_CONST
583 struct ao_lisp_bool *ao_lisp_true, *ao_lisp_false;
585 struct ao_lisp_bool *
586 ao_lisp_bool_get(uint8_t value);
590 extern const struct ao_lisp_type ao_lisp_cons_type;
592 struct ao_lisp_cons *
593 ao_lisp_cons_cons(ao_poly car, ao_poly cdr);
595 /* Return a cons or NULL for a proper list, else error */
596 struct ao_lisp_cons *
597 ao_lisp_cons_cdr(struct ao_lisp_cons *cons);
600 ao_lisp__cons(ao_poly car, ao_poly cdr);
602 extern struct ao_lisp_cons *ao_lisp_cons_free_list;
605 ao_lisp_cons_free(struct ao_lisp_cons *cons);
608 ao_lisp_cons_write(ao_poly);
611 ao_lisp_cons_display(ao_poly);
614 ao_lisp_cons_length(struct ao_lisp_cons *cons);
617 extern const struct ao_lisp_type ao_lisp_string_type;
620 ao_lisp_string_copy(char *a);
623 ao_lisp_string_cat(char *a, char *b);
626 ao_lisp_string_pack(struct ao_lisp_cons *cons);
629 ao_lisp_string_unpack(char *a);
632 ao_lisp_string_write(ao_poly s);
635 ao_lisp_string_display(ao_poly s);
638 extern const struct ao_lisp_type ao_lisp_atom_type;
640 extern struct ao_lisp_atom *ao_lisp_atoms;
641 extern struct ao_lisp_frame *ao_lisp_frame_global;
642 extern struct ao_lisp_frame *ao_lisp_frame_current;
645 ao_lisp_atom_write(ao_poly a);
647 struct ao_lisp_atom *
648 ao_lisp_atom_intern(char *name);
651 ao_lisp_atom_ref(ao_poly atom);
654 ao_lisp_atom_get(ao_poly atom);
657 ao_lisp_atom_set(ao_poly atom, ao_poly val);
660 ao_lisp_atom_def(ao_poly atom, ao_poly val);
664 ao_lisp_int_write(ao_poly i);
667 ao_lisp_poly_integer(ao_poly p);
670 ao_lisp_integer_poly(int32_t i);
673 ao_lisp_integer_typep(uint8_t t)
675 return (t == AO_LISP_INT) || (t == AO_LISP_BIGINT);
679 ao_lisp_bigint_write(ao_poly i);
681 extern const struct ao_lisp_type ao_lisp_bigint_type;
684 ao_lisp_poly_write(ao_poly p);
687 ao_lisp_poly_display(ao_poly p);
690 ao_lisp_poly_mark(ao_poly p, uint8_t note_cons);
692 /* returns 1 if the object has already been moved */
694 ao_lisp_poly_move(ao_poly *p, uint8_t note_cons);
699 ao_lisp_eval_clear_globals(void);
702 ao_lisp_eval_restart(void);
705 ao_lisp_eval(ao_poly p);
708 ao_lisp_set_cond(struct ao_lisp_cons *cons);
711 extern const struct ao_lisp_type ao_lisp_float_type;
714 ao_lisp_float_write(ao_poly p);
717 ao_lisp_float_get(float value);
719 static inline uint8_t
720 ao_lisp_number_typep(uint8_t t)
722 return ao_lisp_integer_typep(t) || (t == AO_LISP_FLOAT);
726 ao_lisp_poly_number(ao_poly p);
730 ao_lisp_builtin_write(ao_poly b);
732 extern const struct ao_lisp_type ao_lisp_builtin_type;
734 /* Check argument count */
736 ao_lisp_check_argc(ao_poly name, struct ao_lisp_cons *cons, int min, int max);
738 /* Check argument type */
740 ao_lisp_check_argt(ao_poly name, struct ao_lisp_cons *cons, int argc, int type, int nil_ok);
742 /* Fetch an arg (nil if off the end) */
744 ao_lisp_arg(struct ao_lisp_cons *cons, int argc);
747 ao_lisp_args_name(uint8_t args);
750 extern struct ao_lisp_cons *ao_lisp_read_cons;
751 extern struct ao_lisp_cons *ao_lisp_read_cons_tail;
752 extern struct ao_lisp_cons *ao_lisp_read_stack;
759 ao_lisp_read_eval_print(void);
762 extern const struct ao_lisp_type ao_lisp_frame_type;
763 extern const struct ao_lisp_type ao_lisp_frame_vals_type;
765 #define AO_LISP_FRAME_FREE 6
767 extern struct ao_lisp_frame *ao_lisp_frame_free_list[AO_LISP_FRAME_FREE];
770 ao_lisp_frame_mark(struct ao_lisp_frame *frame);
773 ao_lisp_frame_ref(struct ao_lisp_frame *frame, ao_poly atom);
775 struct ao_lisp_frame *
776 ao_lisp_frame_new(int num);
779 ao_lisp_frame_free(struct ao_lisp_frame *frame);
782 ao_lisp_frame_bind(struct ao_lisp_frame *frame, int num, ao_poly atom, ao_poly val);
785 ao_lisp_frame_add(struct ao_lisp_frame *frame, ao_poly atom, ao_poly val);
788 ao_lisp_frame_write(ao_poly p);
791 ao_lisp_frame_init(void);
794 extern const struct ao_lisp_type ao_lisp_lambda_type;
796 extern const char *ao_lisp_state_names[];
798 struct ao_lisp_lambda *
799 ao_lisp_lambda_new(ao_poly cons);
802 ao_lisp_lambda_write(ao_poly lambda);
805 ao_lisp_lambda_eval(void);
809 extern const struct ao_lisp_type ao_lisp_stack_type;
810 extern struct ao_lisp_stack *ao_lisp_stack;
811 extern struct ao_lisp_stack *ao_lisp_stack_free_list;
814 ao_lisp_stack_reset(struct ao_lisp_stack *stack);
817 ao_lisp_stack_push(void);
820 ao_lisp_stack_pop(void);
823 ao_lisp_stack_clear(void);
826 ao_lisp_stack_write(ao_poly stack);
829 ao_lisp_stack_eval(void);
834 ao_lisp_vprintf(char *format, va_list args);
837 ao_lisp_printf(char *format, ...);
840 ao_lisp_error_poly(char *name, ao_poly poly, ao_poly last);
843 ao_lisp_error_frame(int indent, char *name, struct ao_lisp_frame *frame);
846 ao_lisp_error(int error, char *format, ...);
850 #define AO_LISP_BUILTIN_DECLS
851 #include "ao_lisp_builtin.h"
853 /* debugging macros */
855 #if DBG_EVAL || DBG_READ || DBG_MEM
857 int ao_lisp_stack_depth;
859 #define DBG_INDENT() do { int _s; for(_s = 0; _s < ao_lisp_stack_depth; _s++) printf(" "); } while(0)
860 #define DBG_IN() (++ao_lisp_stack_depth)
861 #define DBG_OUT() (--ao_lisp_stack_depth)
862 #define DBG_RESET() (ao_lisp_stack_depth = 0)
863 #define DBG(...) ao_lisp_printf(__VA_ARGS__)
864 #define DBGI(...) do { printf("%4d: ", __LINE__); DBG_INDENT(); DBG(__VA_ARGS__); } while (0)
865 #define DBG_CONS(a) ao_lisp_cons_write(ao_lisp_cons_poly(a))
866 #define DBG_POLY(a) ao_lisp_poly_write(a)
867 #define OFFSET(a) ((a) ? (int) ((uint8_t *) a - ao_lisp_pool) : -1)
868 #define DBG_STACK() ao_lisp_stack_write(ao_lisp_stack_poly(ao_lisp_stack))
870 ao_lisp_frames_dump(void)
872 struct ao_lisp_stack *s;
873 DBGI(".. current frame: "); DBG_POLY(ao_lisp_frame_poly(ao_lisp_frame_current)); DBG("\n");
874 for (s = ao_lisp_stack; s; s = ao_lisp_poly_stack(s->prev)) {
875 DBGI(".. stack frame: "); DBG_POLY(s->frame); DBG("\n");
878 #define DBG_FRAMES() ao_lisp_frames_dump()
894 #define RDBGI(...) DBGI(__VA_ARGS__)
895 #define RDBG_IN() DBG_IN()
896 #define RDBG_OUT() DBG_OUT()
903 #define DBG_MEM_START 1
908 extern int dbg_move_depth;
910 #define MDBG_OFFSET(a) ((a) ? (int) ((uint8_t *) (a) - ao_lisp_pool) : -1)
914 #define MDBG_DO(a) DBG_DO(a)
915 #define MDBG_MOVE(...) do { if (dbg_mem) { int d; for (d = 0; d < dbg_move_depth; d++) printf (" "); printf(__VA_ARGS__); } } while (0)
916 #define MDBG_MORE(...) do { if (dbg_mem) printf(__VA_ARGS__); } while (0)
917 #define MDBG_MOVE_IN() (dbg_move_depth++)
918 #define MDBG_MOVE_OUT() (assert(--dbg_move_depth >= 0))
923 #define MDBG_MOVE(...)
924 #define MDBG_MORE(...)
925 #define MDBG_MOVE_IN()
926 #define MDBG_MOVE_OUT()
930 #endif /* _AO_LISP_H_ */