Missed FREAD in bytecode.h
[p5sagit/p5-mst-13.2.git] / bytecode.h
index 2cdc028..f605e27 100644 (file)
@@ -8,28 +8,32 @@ typedef OP *opindex;
 typedef IV IV64;
 
 EXT int iv_overflows INIT(0);
-void *bset_obj_store _((void *, I32));
-void freadpv _((U32, void *));
 
 EXT SV *sv;
+#ifndef USE_THREADS
 EXT OP *op;
+#endif
 EXT XPV pv;
 
 EXT void **obj_list;
 EXT I32 obj_list_fill INIT(-1);
 
 #ifdef INDIRECT_BGET_MACROS
-#define FREAD(argp, len, nelem) bs.fread((char*)(argp),(len),(nelem),bs.data)
-#define FGETC() bs.fgetc(bs.data)
+#define BGET_FREAD(argp, len, nelem)   \
+        bs.fread((char*)(argp),(len),(nelem),bs.data)
+#define BGET_FGETC() bs.fgetc(bs.data)
 #else
-#define FREAD(argp, len, nelem) fread((argp), (len), (nelem), fp)
-#define FGETC() getc(fp)
+#define BGET_FREAD(argp, len, nelem) fread((argp), (len), (nelem), fp)
+#define BGET_FGETC() getc(fp)
 #endif /* INDIRECT_BGET_MACROS */
 
-#define BGET_U32(arg)  FREAD(&arg, sizeof(U32), 1); arg = ntohl((U32)arg)
-#define BGET_I32(arg)  FREAD(&arg, sizeof(I32), 1); arg = (I32)ntohl((U32)arg)
-#define BGET_U16(arg)  FREAD(&arg, sizeof(U16), 1); arg = ntohs((U16)arg)
-#define BGET_U8(arg)   arg = FGETC()
+#define BGET_U32(arg)  \
+       BGET_FREAD(&arg, sizeof(U32), 1); arg = ntohl((U32)arg)
+#define BGET_I32(arg)  \
+       BGET_FREAD(&arg, sizeof(I32), 1); arg = (I32)ntohl((U32)arg)
+#define BGET_U16(arg)  \
+       BGET_FREAD(&arg, sizeof(U16), 1); arg = ntohs((U16)arg)
+#define BGET_U8(arg)   arg = BGET_FGETC()
 
 #if INDIRECT_BGET_MACROS
 #define BGET_PV(arg)   do {            \
@@ -59,7 +63,7 @@ EXT I32 obj_list_fill INIT(-1);
 #endif /* INDIRECT_BGET_MACROS */
 
 #define BGET_comment(arg) \
-       do { arg = FGETC(); } while (arg != '\n' && arg != EOF)
+       do { arg = BGET_FGETC(); } while (arg != '\n' && arg != EOF)
 
 /*
  * In the following, sizeof(IV)*4 is just a way of encoding 32 on 64-bit-IV
@@ -86,7 +90,7 @@ EXT I32 obj_list_fill INIT(-1);
        unsigned short *ary;            \
        int i;                          \
        New(666, ary, 256, unsigned short); \
-       FREAD(ary, 256, 2);             \
+       BGET_FREAD(ary, 256, 2);        \
        for (i = 0; i < 256; i++)       \
            ary[i] = ntohs(ary[i]);     \
        arg = (char *) ary;             \
@@ -94,7 +98,7 @@ EXT I32 obj_list_fill INIT(-1);
 
 #define BGET_pvcontents(arg)   arg = pv.xpv_pv
 #define BGET_strconst(arg)     do {    \
-       for (arg = tokenbuf; (*arg = FGETC()); arg++) /* nothing */;    \
+       for (arg = tokenbuf; (*arg = BGET_FGETC()); arg++) /* nothing */; \
        arg = tokenbuf;                 \
     } while (0)
 
@@ -135,14 +139,15 @@ EXT I32 obj_list_fill INIT(-1);
 #define BSET_hv_store(sv, arg) \
        hv_store((HV*)sv, pv.xpv_pv, pv.xpv_cur, arg, 0)
 #define BSET_pv_free(pv)       Safefree(pv.xpv_pv)
-#define BSET_pregcomp(op, arg) \
-       cPMOP->op_pmregexp = arg ? pregcomp(arg, arg + pv.xpv_cur, cPMOP) : 0
+#define BSET_pregcomp(o, arg) \
+       ((PMOP*)o)->op_pmregexp = arg ? \
+               pregcomp(arg, arg + pv.xpv_cur, ((PMOP*)o)) : 0
 #define BSET_newsv(sv, arg)    sv = NEWSV(666,0); SvUPGRADE(sv, arg)
-#define BSET_newop(op, arg)    op = (OP*)safemalloc(optype_size[arg])
-#define BSET_newopn(op, arg)   do {    \
-       OP *oldop = op;                 \
-       BSET_newop(op, arg);            \
-       oldop->op_next = op;            \
+#define BSET_newop(o, arg)     o = (OP*)safemalloc(optype_size[arg])
+#define BSET_newopn(o, arg)    do {    \
+       OP *oldop = o;                  \
+       BSET_newop(o, arg);             \
+       oldop->op_next = o;             \
     } while (0)
 
 #define BSET_ret(foo) return
@@ -151,11 +156,13 @@ EXT I32 obj_list_fill INIT(-1);
  * Kludge special-case workaround for OP_MAPSTART
  * which needs the ppaddr for OP_GREPSTART. Blech.
  */
-#define BSET_op_type(op, arg)  do {    \
-       op->op_type = arg;              \
-       op->op_ppaddr = (arg != OP_MAPSTART) ? ppaddr[arg] : pp_grepstart; \
+#define BSET_op_type(o, arg)   do {    \
+       o->op_type = arg;               \
+       if (arg == OP_MAPSTART)         \
+           arg = OP_GREPSTART;         \
+       o->op_ppaddr = ppaddr[arg];     \
     } while (0)
-#define BSET_op_ppaddr(op, arg) croak("op_ppaddr not yet implemented")
+#define BSET_op_ppaddr(o, arg) croak("op_ppaddr not yet implemented")
 #define BSET_curpad(pad, arg) pad = AvARRAY(arg)
 
 #define BSET_OBJ_STORE(obj, ix)                \