don't longjmp() in pp_goto() (regressive bug from old single-stack
[p5sagit/p5-mst-13.2.git] / scope.h
diff --git a/scope.h b/scope.h
index 24d98e4..a9d4ba3 100644 (file)
--- a/scope.h
+++ b/scope.h
@@ -26,6 +26,7 @@
 #define SAVEt_HELEM     25
 #define SAVEt_OP       26
 #define SAVEt_HINTS    27
+#define SAVEt_ALLOC    28
 
 #define SSCHECK(need) if (PL_savestack_ix + need > PL_savestack_max) savestack_grow()
 #define SSPUSHINT(i) (PL_savestack[PL_savestack_ix++].any_i32 = (I32)(i))
        }                                       \
     } STMT_END
 
+/* SSNEW() temporarily allocates a specified number of bytes of data on the
+ * savestack.  It returns an integer index into the savestack, because a
+ * pointer would get broken if the savestack is moved on reallocation.
+ * SSNEWa() works like SSNEW(), but also aligns the data to the specified
+ * number of bytes.  MEM_ALIGNBYTES is perhaps the most useful.  The
+ * alignment will be preserved therough savestack reallocation *only* if
+ * realloc returns data aligned to a size divisible by `align'!
+ *
+ * SSPTR() converts the index returned by SSNEW/SSNEWa() into a pointer.
+ */
+
+#define SSNEW(size)             save_alloc(size, 0)
+#define SSNEWa(size,align)     save_alloc(size, \
+    (align - ((int)((caddr_t)&PL_savestack[PL_savestack_ix]) % align)) % align)
+
+#define SSPTR(off,type)         ((type) ((char*)PL_savestack + off))
+
 /* A jmpenv packages the state required to perform a proper non-local jump.
  * Note that there is a start_env initialized when perl starts, and top_env
  * points to this initially, so top_env should always be non-null.
@@ -135,8 +153,8 @@ struct jmpenv {
 typedef struct jmpenv JMPENV;
 
 #ifdef OP_IN_REGISTER
-#define OP_REG_TO_MEM  opsave = op
-#define OP_MEM_TO_REG  op = opsave
+#define OP_REG_TO_MEM  PL_opsave = op
+#define OP_MEM_TO_REG  op = PL_opsave
 #else
 #define OP_REG_TO_MEM  NOOP
 #define OP_MEM_TO_REG  NOOP