summaryrefslogtreecommitdiffstats
path: root/unwind.h
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2013-10-24 21:49:52 -0700
committerKaz Kylheku <kaz@kylheku.com>2013-10-24 21:49:52 -0700
commitc6862a210f48ee4fd2d7fe7ad0e4eca11bea9963 (patch)
treeea18db3c64d4edfd8dc17784211d382a434fca45 /unwind.h
parentb7f9a8f2e02872fea86827b034278c399fb052dc (diff)
downloadtxr-c6862a210f48ee4fd2d7fe7ad0e4eca11bea9963.tar.gz
txr-c6862a210f48ee4fd2d7fe7ad0e4eca11bea9963.tar.bz2
txr-c6862a210f48ee4fd2d7fe7ad0e4eca11bea9963.zip
Ouch! Turns out the code base has numerous unintended
deviations from C90, like mixed declations and statements. GCC doesn't diagnose these without the --pedantic flag. * configure: GCC's --ansi flag should be spelled -ansi. * lib.c (split_str, obj_print): Reorder declaration before statements. (make_sym): Fix similar problem by eliminating a statement. (funcall1, funcall2, funcall3, funcall4): Use assignment to initialize local array with non-constant elements. This is actually good for performance because we only initialize those parts of the array that we use. * lib.h (struct func): Change functype member to unsigned, since enum-typed bitfields are a GCC extension. * match.c (ml_all, mf_all): Use assignments to initialize local struct with non-constants. (do_txeval, v_collect): Slightly revise unwinding macrology with help of new macros to avoid mixing declarations and statements. (spec_bind): Removed spurious semicolon from macro expansion. (v_gather): Reorder two lines to avoid mixed decls and statements. (match_filter): Move declaration of ret a few lines up, ahead of statements. * unwind.c (uw_pop_until): New function. * unwind.h (uw_pop_until): Declared. (uw_mark_frame, uw_fast_return): New macros.
Diffstat (limited to 'unwind.h')
-rw-r--r--unwind.h13
1 files changed, 11 insertions, 2 deletions
diff --git a/unwind.h b/unwind.h
index db8a53fa..9d584a2a 100644
--- a/unwind.h
+++ b/unwind.h
@@ -110,16 +110,25 @@ void uw_push_debug(uw_frame_t *, val func, val args,
val ub_p_a_pairs, val env, val data,
val line, val chr);
void uw_pop_frame(uw_frame_t *);
+void uw_pop_until(uw_frame_t *);
uw_frame_t *uw_current_frame(void);
uw_frame_t *uw_current_exit_point(void);
void uw_init(void);
noreturn val type_mismatch(val, ...);
+#define uw_mark_frame \
+ uw_frame_t *uw_top = uw_current_frame()
+
+#define uw_fast_return(VAL) \
+ do { \
+ uw_pop_until(uw_top); \
+ return VAL; \
+ } while (0)
+
#define uw_block_begin(TAG, RESULTVAR) \
obj_t *RESULTVAR = nil; \
- do \
- { \
+ do { \
uw_frame_t uw_blk; \
uw_push_block(&uw_blk, TAG); \
if (setjmp(uw_blk.bl.jb)) { \