X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=bytecode.h;h=fadc28f0b97ac7a7ca7527dfbbac450ca91a9304;hb=f2f2613b8fd93f228ac9506438022acbc86e641f;hp=4676b5ad601ac19af0fb4063e9e715de432a461b;hpb=f7d144c835d02593edb2388cf7cb0c7395c53ae2;p=p5sagit%2Fp5-mst-13.2.git diff --git a/bytecode.h b/bytecode.h index 4676b5a..fadc28f 100644 --- a/bytecode.h +++ b/bytecode.h @@ -2,37 +2,26 @@ 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; -EXT int iv_overflows INIT(0); - -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 BGET_FREAD(argp, len, nelem) \ 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 @@ -41,28 +30,28 @@ EXT I32 obj_list_fill INIT(-1); if (arg) \ bs.freadpv(arg, bs.data); \ else { \ - pv.xpv_pv = 0; \ - pv.xpv_len = 0; \ - pv.xpv_cur = 0; \ + PL_bytecode_pv.xpv_pv = 0; \ + PL_bytecode_pv.xpv_len = 0; \ + PL_bytecode_pv.xpv_cur = 0; \ } \ } STMT_END #else #define BGET_PV(arg) STMT_START { \ BGET_U32(arg); \ if (arg) { \ - New(666, pv.xpv_pv, arg, char); \ - PerlIO_fread(pv.xpv_pv, 1, arg, fp);\ - pv.xpv_len = arg; \ - pv.xpv_cur = arg - 1; \ + New(666, PL_bytecode_pv.xpv_pv, arg, char); \ + PerlIO_read(fp, PL_bytecode_pv.xpv_pv, arg); \ + PL_bytecode_pv.xpv_len = arg; \ + PL_bytecode_pv.xpv_cur = arg - 1; \ } else { \ - pv.xpv_pv = 0; \ - pv.xpv_len = 0; \ - pv.xpv_cur = 0; \ + PL_bytecode_pv.xpv_pv = 0; \ + PL_bytecode_pv.xpv_len = 0; \ + PL_bytecode_pv.xpv_cur = 0; \ } \ } STMT_END #endif /* INDIRECT_BGET_MACROS */ -#define BGET_comment(arg) \ +#define BGET_comment_t(arg) \ do { arg = BGET_FGETC(); } while (arg != '\n' && arg != EOF) /* @@ -81,7 +70,7 @@ EXT I32 obj_list_fill INIT(-1); arg = (I32)lo; \ } \ else { \ - iv_overflows++; \ + PL_bytecode_iv_overflows++; \ arg = 0; \ } \ } STMT_END @@ -92,14 +81,14 @@ 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) -#define BGET_pvcontents(arg) arg = pv.xpv_pv +#define BGET_pvcontents(arg) arg = PL_bytecode_pv.xpv_pv #define BGET_strconst(arg) STMT_START { \ - for (arg = tokenbuf; (*arg = BGET_FGETC()); arg++) /* nothing */; \ - arg = tokenbuf; \ + for (arg = PL_tokenbuf; (*arg = BGET_FGETC()); arg++) /* nothing */; \ + arg = PL_tokenbuf; \ } STMT_END #define BGET_double(arg) STMT_START { \ @@ -108,13 +97,15 @@ 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)PL_bytecode_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] +#define BSET_ldspecsv(sv, arg) sv = PL_specialsv_list[arg] #define BSET_sv_refcnt_add(svrefcnt, arg) svrefcnt += arg #define BSET_gp_refcnt_add(gprefcnt, arg) gprefcnt += arg @@ -126,22 +117,22 @@ EXT I32 obj_list_fill INIT(-1); #define BSET_gv_fetchpv(sv, arg) sv = (SV*)gv_fetchpv(arg, TRUE, SVt_PV) #define BSET_gv_stashpv(sv, arg) sv = (SV*)gv_stashpv(arg, TRUE) #define BSET_sv_magic(sv, arg) sv_magic(sv, Nullsv, arg, 0, 0) -#define BSET_mg_pv(mg, arg) mg->mg_ptr = arg; mg->mg_len = pv.xpv_cur +#define BSET_mg_pv(mg, arg) mg->mg_ptr = arg; mg->mg_len = PL_bytecode_pv.xpv_cur #define BSET_sv_upgrade(sv, arg) (void)SvUPGRADE(sv, arg) #define BSET_xpv(sv) do { \ - SvPV_set(sv, pv.xpv_pv); \ - SvCUR_set(sv, pv.xpv_cur); \ - SvLEN_set(sv, pv.xpv_len); \ + SvPV_set(sv, PL_bytecode_pv.xpv_pv); \ + SvCUR_set(sv, PL_bytecode_pv.xpv_cur); \ + SvLEN_set(sv, PL_bytecode_pv.xpv_len); \ } while (0) #define BSET_av_extend(sv, arg) av_extend((AV*)sv, arg) #define BSET_av_push(sv, arg) av_push((AV*)sv, arg) #define BSET_hv_store(sv, arg) \ - hv_store((HV*)sv, pv.xpv_pv, pv.xpv_cur, arg, 0) + hv_store((HV*)sv, PL_bytecode_pv.xpv_pv, PL_bytecode_pv.xpv_cur, arg, 0) #define BSET_pv_free(pv) Safefree(pv.xpv_pv) #define BSET_pregcomp(o, arg) \ ((PMOP*)o)->op_pmregexp = arg ? \ - pregcomp(arg, arg + pv.xpv_cur, ((PMOP*)o)) : 0 + CALLREGCOMP(arg, arg + PL_bytecode_pv.xpv_cur, ((PMOP*)o)) : 0 #define BSET_newsv(sv, arg) sv = NEWSV(666,0); SvUPGRADE(sv, arg) #define BSET_newop(o, arg) o = (OP*)safemalloc(optype_size[arg]) #define BSET_newopn(o, arg) STMT_START { \ @@ -160,11 +151,11 @@ EXT I32 obj_list_fill INIT(-1); o->op_type = arg; \ if (arg == OP_MAPSTART) \ arg = OP_GREPSTART; \ - o->op_ppaddr = ppaddr[arg]; \ + o->op_ppaddr = PL_ppaddr[arg]; \ } STMT_END #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) \ - (I32)ix > obj_list_fill ? \ - bset_obj_store(obj, (I32)ix) : (obj_list[ix] = obj) + (I32)ix > PL_bytecode_obj_list_fill ? \ + bset_obj_store(obj, (I32)ix) : (PL_bytecode_obj_list[ix] = obj)