X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=ext%2FOpcode%2FOpcode.xs;h=22d424d9366c0172680fb6ad04803e55170163c7;hb=9d8a25dc64d23dcd5730db9be0dbe94a107e1f8b;hp=28678ed0f8b3a24f11483153e092fd6fc3fef554;hpb=bf81aadd817bdea29720b072eef945df2da8463b;p=p5sagit%2Fp5-mst-13.2.git diff --git a/ext/Opcode/Opcode.xs b/ext/Opcode/Opcode.xs index 28678ed..22d424d 100644 --- a/ext/Opcode/Opcode.xs +++ b/ext/Opcode/Opcode.xs @@ -24,18 +24,20 @@ static SV *get_op_bitspec _((char *opname, STRLEN len, int fatal)); */ static void -op_names_init() +op_names_init(void) { int i; STRLEN len; - char *opname; + char **op_names; char *bitmap; op_named_bits = newHV(); + op_names = get_op_names(); for(i=0; i < maxo; ++i) { - hv_store(op_named_bits, op_name[i],strlen(op_name[i]), - Sv=newSViv(i), 0); - SvREADONLY_on(Sv); + SV *sv; + sv = newSViv(i); + SvREADONLY_on(sv); + hv_store(op_named_bits, op_names[i], strlen(op_names[i]), sv, 0); } put_op_bitspec(":none",0, sv_2mortal(new_opset(Nullsv))); @@ -46,7 +48,7 @@ op_names_init() while(i-- > 0) bitmap[i] = 0xFF; /* Take care to set the right number of bits in the last byte */ - bitmap[len-1] = (maxo & 0x07) ? ~(~0 << (maxo & 0x07)) : 0xFF; + bitmap[len-1] = (maxo & 0x07) ? ~(0xFF << (maxo & 0x07)) : 0xFF; put_op_bitspec(":all",0, opset_all); /* don't mortalise */ } @@ -57,10 +59,7 @@ op_names_init() */ static void -put_op_bitspec(optag, len, mask) - char *optag; - STRLEN len; - SV *mask; +put_op_bitspec(char *optag, STRLEN len, SV *mask) { SV **svp; verify_opset(mask,1); @@ -81,10 +80,7 @@ put_op_bitspec(optag, len, mask) */ static SV * -get_op_bitspec(opname, len, fatal) - char *opname; - STRLEN len; - int fatal; +get_op_bitspec(char *opname, STRLEN len, int fatal) { SV **svp; if (!len) @@ -107,8 +103,7 @@ get_op_bitspec(opname, len, fatal) static SV * -new_opset(old_opset) - SV *old_opset; +new_opset(SV *old_opset) { SV *opset; if (old_opset) { @@ -116,8 +111,8 @@ new_opset(old_opset) opset = newSVsv(old_opset); } else { - opset = newSV(opset_len); - Zero(SvPVX(opset), opset_len, char); + opset = NEWSV(1156, opset_len); + Zero(SvPVX(opset), opset_len + 1, char); SvCUR_set(opset, opset_len); (void)SvPOK_only(opset); } @@ -127,9 +122,7 @@ new_opset(old_opset) static int -verify_opset(opset, fatal) - SV *opset; - int fatal; +verify_opset(SV *opset, int fatal) { char *err = Nullch; if (!SvOK(opset)) err = "undefined"; @@ -143,11 +136,7 @@ verify_opset(opset, fatal) static void -set_opset_bits(bitmap, bitspec, on, opname) - char *bitmap; - SV *bitspec; - int on; - char *opname; +set_opset_bits(char *bitmap, SV *bitspec, int on, char *opname) { if (SvIOK(bitspec)) { int myopcode = SvIV(bitspec); @@ -175,14 +164,13 @@ set_opset_bits(bitmap, bitspec, on, opname) while(len-- > 0) bitmap[len] &= ~specbits[len]; } else - croak("panic: invalid bitspec for \"%s\" (type %lu)", - opname, (unsigned long)SvTYPE(bitspec)); + croak("panic: invalid bitspec for \"%s\" (type %u)", + opname, (unsigned)SvTYPE(bitspec)); } static void -opmask_add(opset) /* THE ONLY FUNCTION TO EDIT op_mask ITSELF */ - SV *opset; +opmask_add(SV *opset) /* THE ONLY FUNCTION TO EDIT op_mask ITSELF */ { int i,j; char *bitmask; @@ -209,14 +197,12 @@ opmask_add(opset) /* THE ONLY FUNCTION TO EDIT op_mask ITSELF */ } static void -opmask_addlocal(opset, op_mask_buf) /* Localise op_mask then opmask_add() */ - SV *opset; - char *op_mask_buf; +opmask_addlocal(SV *opset, char *op_mask_buf) /* Localise op_mask then opmask_add() */ { char *orig_op_mask = op_mask; SAVEPPTR(op_mask); if (opcode_debug >= 2) - SAVEDESTRUCTOR((void(*)_((void*)))warn,"op_mask restored"); + SAVEDESTRUCTOR((void(CPERLscope(*))_((void*)))warn,"op_mask restored"); op_mask = &op_mask_buf[0]; if (orig_op_mask) Copy(orig_op_mask, op_mask, maxo, char); @@ -240,8 +226,8 @@ BOOT: void -_safe_call_sv(package, mask, codesv) - char * package +_safe_call_sv(Package, mask, codesv) + char * Package SV * mask SV * codesv PPCODE: @@ -257,7 +243,7 @@ _safe_call_sv(package, mask, codesv) save_hptr(&defstash); /* save current default stack */ /* the assignment to global defstash changes our sense of 'main' */ - defstash = gv_stashpv(package, GV_ADDWARN); /* should exist already */ + defstash = gv_stashpv(Package, GV_ADDWARN); /* should exist already */ /* defstash must itself contain a main:: so we'll add that now */ /* take care with the ref counts (was cause of long standing bug) */ @@ -290,7 +276,8 @@ invert_opset(opset) while(len-- > 0) bitmap[len] = ~bitmap[len]; /* take care of extra bits beyond maxo in last byte */ - bitmap[opset_len-1] &= ~(0xFF << (maxo & 0x0F)); + if (maxo & 07) + bitmap[opset_len-1] &= ~(0xFF << (maxo & 0x07)); } ST(0) = opset; @@ -304,7 +291,7 @@ opset_to_ops(opset, desc = 0) STRLEN len; int i, j, myopcode; char *bitmap = SvPV(opset, len); - char **names = (desc) ? op_desc : op_name; + char **names = (desc) ? get_op_descs() : get_op_names(); verify_opset(opset,1); for (myopcode=0, i=0; i < opset_len; i++) { U16 bits = bitmap[i]; @@ -389,6 +376,7 @@ opdesc(...) int i, myopcode; STRLEN len; SV **args; + char **op_desc = get_op_descs(); /* copy args to a scratch area since we may push output values onto */ /* the stack faster than we read values off it if masks are used. */ args = (SV**)SvPVX(sv_2mortal(newSVpv((char*)&ST(0), items*sizeof(SV*)))); @@ -413,8 +401,8 @@ opdesc(...) } } else - croak("panic: invalid bitspec for \"%s\" (type %lu)", - opname, (unsigned long)SvTYPE(bitspec)); + croak("panic: invalid bitspec for \"%s\" (type %u)", + opname, (unsigned)SvTYPE(bitspec)); }