Commits

Armin Rigo committed 63f8a52

tweaks

  • Participants
  • Parent commits fd80fbd

Comments (0)

Files changed (2)

File hack/pypy-hack/rewind_setjmp/rewind_setjmp.c

 
 __thread struct _rewind_jmp_s _rewind_jmp;
 
-#define JMPBUF_TRAP_INDEX   1
-#define JMPBUF_TRAP         ((void *)-1)
-
 
 struct _rewind_jmp_moved_s {
     struct _rewind_jmp_moved_s *next;
 
 
 __attribute__((noinline, noreturn))
-void rewind_jmp_longjmp(void)
+void _rewind_jmp_longjmp(char *stack_free)
 {
     assert(_rewind_jmp.moved_off_base != NULL);
 
     while (_rewind_jmp.moved_off) {
         struct _rewind_jmp_moved_s *p = _rewind_jmp.moved_off;
-        char *stack_free = (char *)_rewind_jmp.head;
         char *target = (char *)_rewind_jmp.moved_off_base;
         target -= p->size;
         if (target < stack_free) {
             /* need more stack space! */
-            _rewind_jmp.head = (rewind_jmp_buf *) alloca(stack_free - target);
-            rewind_jmp_longjmp();
+            _rewind_jmp_longjmp(alloca(stack_free - target));
         }
         memcpy(target, ((char *)p) + RJM_HEADER, p->size);
         _rewind_jmp.moved_off_base = target;
         _rewind_jmp.moved_off = p->next;
         free(p);
     }
-
-    assert(_rewind_jmp.jmpbuf[JMPBUF_TRAP_INDEX] != JMPBUF_TRAP);
+    _rewind_jmp.head = _rewind_jmp.moved_off_base;
     __builtin_longjmp(_rewind_jmp.jmpbuf);
 }
 
         p = pnext;
     }
     _rewind_jmp.moved_off = NULL;
-    _rewind_jmp.jmpbuf[JMPBUF_TRAP_INDEX] = JMPBUF_TRAP;
+    _rewind_jmp.moved_off_base = NULL;
 }

File hack/pypy-hack/rewind_setjmp/rewind_setjmp.h

     _rewind_jmp.moved_off_base = _rewind_jmp.head;              \
 } while (0)
 
+#define rewind_jmp_longjmp()   do {                     \
+    char _rewind_jmp_marker;                            \
+    _rewind_jmp_longjmp(&_rewind_jmp_marker);           \
+} while (0)
+
 #define rewind_jmp_forget()  do {                               \
     if (_rewind_jmp.moved_off) _rewind_jmp_free_stack_slices(); \
     _rewind_jmp.moved_off_base = 0;                             \
 } while (0)
 
-void rewind_jmp_longjmp(void);
+void _rewind_jmp_longjmp(char *);
 void _rewind_jmp_copy_stack_slice(void);
 void _rewind_jmp_free_stack_slices(void);