This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
add newer malloc.c from Ilya Zakharevich <ilya@math.ohio-state.edu>
[perl5.git] / bytecode.h
index 4676b5a..3e8a6a9 100644 (file)
@@ -2,7 +2,7 @@ typedef char *pvcontents;
 typedef char *strconst;
 typedef U32 PV;
 typedef char *op_tr_array;
-typedef int comment;
+typedef int comment_t;
 typedef SV *svindex;
 typedef OP *opindex;
 typedef IV IV64;
@@ -23,16 +23,16 @@ EXT I32 obj_list_fill INIT(-1);
         bs.fread((char*)(argp),(len),(nelem),bs.data)
 #define BGET_FGETC() bs.fgetc(bs.data)
 #else
-#define BGET_FREAD(argp, len, nelem) PerlIO_fread((argp), (len), (nelem), fp)
+#define BGET_FREAD(argp, len, nelem) PerlIO_read(fp, (argp), (len)*(nelem))
 #define BGET_FGETC() PerlIO_getc(fp)
 #endif /* INDIRECT_BGET_MACROS */
 
 #define BGET_U32(arg)  \
-       BGET_FREAD(&arg, sizeof(U32), 1); arg = ntohl((U32)arg)
+       BGET_FREAD(&arg, sizeof(U32), 1); arg = PerlSock_ntohl((U32)arg)
 #define BGET_I32(arg)  \
-       BGET_FREAD(&arg, sizeof(I32), 1); arg = (I32)ntohl((U32)arg)
+       BGET_FREAD(&arg, sizeof(I32), 1); arg = (I32)PerlSock_ntohl((U32)arg)
 #define BGET_U16(arg)  \
-       BGET_FREAD(&arg, sizeof(U16), 1); arg = ntohs((U16)arg)
+       BGET_FREAD(&arg, sizeof(U16), 1); arg = PerlSock_ntohs((U16)arg)
 #define BGET_U8(arg)   arg = BGET_FGETC()
 
 #if INDIRECT_BGET_MACROS
@@ -51,7 +51,7 @@ EXT I32 obj_list_fill INIT(-1);
        BGET_U32(arg);                          \
        if (arg) {                              \
            New(666, pv.xpv_pv, arg, char);     \
-           PerlIO_fread(pv.xpv_pv, 1, arg, fp);\
+           PerlIO_read(fp, pv.xpv_pv, arg);    \
            pv.xpv_len = arg;                   \
            pv.xpv_cur = arg - 1;               \
        } else {                                \
@@ -92,7 +92,7 @@ EXT I32 obj_list_fill INIT(-1);
        New(666, ary, 256, unsigned short); \
        BGET_FREAD(ary, 256, 2);        \
        for (i = 0; i < 256; i++)       \
-           ary[i] = ntohs(ary[i]);     \
+           ary[i] = PerlSock_ntohs(ary[i]);    \
        arg = (char *) ary;             \
     } while (0)
 
@@ -108,11 +108,13 @@ EXT I32 obj_list_fill INIT(-1);
        arg = atof(str);                \
     } STMT_END
 
-#define BGET_objindex(arg) STMT_START {        \
-       U32 ix;                         \
-       BGET_U32(ix);                   \
-       arg = obj_list[ix];             \
+#define BGET_objindex(arg, type) STMT_START {  \
+       U32 ix;                                 \
+       BGET_U32(ix);                           \
+       arg = (type)obj_list[ix];               \
     } STMT_END
+#define BGET_svindex(arg) BGET_objindex(arg, svindex)
+#define BGET_opindex(arg) BGET_objindex(arg, opindex)
 
 #define BSET_ldspecsv(sv, arg) sv = specialsv_list[arg]