+2013-10-03 Paul Eggert <eggert@cs.ucla.edu>
+
+ * eval.c (clobbered_eassert): New macro.
+ (internal_catch, internal_condition_case)
+ (internal_condition_case_1, internal_condition_case_2)
+ (internal_condition_case_n): Use it instead of eassert
+ when the argument contains locals clobbered by longjmp.
+ Don't use clobbered locals outside of clobbered_eassert.
+ (internal_lisp_condition_case): Use a volatile variable
+ to work around a local variable's getting clobbered.
+
2013-10-03 Stefan Monnier <monnier@iro.umontreal.ca>
* lisp.h (struct handler): Merge struct handler and struct catchtag.
return internal_catch (tag, Fprogn, XCDR (args));
}
+/* Assert that E is true, as a comment only. Use this instead of
+ eassert (E) when E contains variables that might be clobbered by a
+ longjmp. */
+
+#define clobbered_eassert(E) ((void) 0)
+
/* Set up a catch, then call C function FUNC on argument ARG.
FUNC should return a Lisp_Object.
This is how catches are done from within C code. */
if (! sys_setjmp (c->jmp))
{
Lisp_Object val = (*func) (arg);
- eassert (handlerlist == c);
- handlerlist = c->next;
+ clobbered_eassert (handlerlist == c);
+ handlerlist = handlerlist->next;
return val;
}
else
{ /* Throw works by a longjmp that comes right here. */
Lisp_Object val = handlerlist->val;
- eassert (handlerlist == c);
+ clobbered_eassert (handlerlist == c);
handlerlist = handlerlist->next;
return val;
}
be added to handlerlist last. So we build in `clauses' a table that
contains `handlers' but in reverse order. */
Lisp_Object *clauses = alloca (clausenb * sizeof (Lisp_Object *));
+ Lisp_Object *volatile clauses_volatile = clauses;
int i = clausenb;
for (val = handlers; CONSP (val); val = XCDR (val))
clauses[--i] = XCAR (val);
{
ptrdiff_t count = SPECPDL_INDEX ();
Lisp_Object val = handlerlist->val;
- Lisp_Object *chosen_clause = clauses;
+ Lisp_Object *chosen_clause = clauses_volatile;
for (c = handlerlist->next; c != oldhandlerlist; c = c->next)
chosen_clause++;
handlerlist = oldhandlerlist;
if (sys_setjmp (c->jmp))
{
Lisp_Object val = handlerlist->val;
- eassert (handlerlist == c);
+ clobbered_eassert (handlerlist == c);
handlerlist = handlerlist->next;
return (*hfun) (val);
}
val = (*bfun) ();
- eassert (handlerlist == c);
- handlerlist = c->next;
+ clobbered_eassert (handlerlist == c);
+ handlerlist = handlerlist->next;
return val;
}
if (sys_setjmp (c->jmp))
{
Lisp_Object val = handlerlist->val;
- eassert (handlerlist == c);
+ clobbered_eassert (handlerlist == c);
handlerlist = handlerlist->next;
return (*hfun) (val);
}
val = (*bfun) (arg);
- eassert (handlerlist == c);
- handlerlist = c->next;
+ clobbered_eassert (handlerlist == c);
+ handlerlist = handlerlist->next;
return val;
}
if (sys_setjmp (c->jmp))
{
Lisp_Object val = handlerlist->val;
- eassert (handlerlist == c);
+ clobbered_eassert (handlerlist == c);
handlerlist = handlerlist->next;
return (*hfun) (val);
}
val = (*bfun) (arg1, arg2);
- eassert (handlerlist == c);
- handlerlist = c->next;
+ clobbered_eassert (handlerlist == c);
+ handlerlist = handlerlist->next;
return val;
}
if (sys_setjmp (c->jmp))
{
Lisp_Object val = handlerlist->val;
- eassert (handlerlist == c);
+ clobbered_eassert (handlerlist == c);
handlerlist = handlerlist->next;
return (*hfun) (val, nargs, args);
}
val = (*bfun) (nargs, args);
- eassert (handlerlist == c);
- handlerlist = c->next;
+ clobbered_eassert (handlerlist == c);
+ handlerlist = handlerlist->next;
return val;
}