#define MY_CXT_KEY __PACKAGE__ "::_guts" XS_VERSION
-typedef struct {
- HV *wizz;
- U16 count;
-} my_cxt_t;
+typedef HV * my_cxt_t;
START_MY_CXT
do {
sig = SIG_NBR * Drand01() + SIG_MIN;
- } while (hv_exists(MY_CXT.wizz, buf, sprintf(buf, "%u", sig)));
+ } while (hv_exists(MY_CXT, buf, sprintf(buf, "%u", sig)));
return sig;
}
#endif /* VMG_MULTIPLICITY */
dMY_CXT;
- if (hv_delete(MY_CXT.wizz, buf, sprintf(buf, "%u", w->sig), 0)) {
- --MY_CXT.count;
- }
+ wiz = hv_delete(MY_CXT, buf, sprintf(buf, "%u", w->sig), 0);
SvFLAGS(wiz) |= SVf_BREAK;
FREETMPS;
dMY_CXT;
- if (!hv_fetch(MY_CXT.wizz, buf, sprintf(buf, "%u", sig), 0))
+ if (!hv_fetch(MY_CXT, buf, sprintf(buf, "%u", sig), 0))
sig = 0;
return sig;
dMY_CXT;
- return (old = hv_fetch(MY_CXT.wizz, buf, sprintf(buf, "%u", sig), 0))
+ return (old = hv_fetch(MY_CXT, buf, sprintf(buf, "%u", sig), 0))
? *old : NULL;
}
{
HV *stash;
MY_CXT_INIT;
- MY_CXT.wizz = newHV();
- hv_iterinit(MY_CXT.wizz); /* Allocate iterator */
- MY_CXT.count = 0;
+ MY_CXT = newHV();
+ hv_iterinit(MY_CXT); /* Allocate iterator */
stash = gv_stashpv(__PACKAGE__, 1);
newCONSTSUB(stash, "SIG_MIN", newSVuv(SIG_MIN));
newCONSTSUB(stash, "SIG_MAX", newSVuv(SIG_MAX));
{
HE *key;
dMY_CXT;
- count = MY_CXT.count;
hv = newHV();
hv_iterinit(hv); /* Allocate iterator */
- hv_iterinit(MY_CXT.wizz);
- while (key = hv_iternext(MY_CXT.wizz)) {
+ hv_iterinit(MY_CXT);
+ while (key = hv_iternext(MY_CXT)) {
STRLEN len;
char *sig = HePV(key, len);
SV *sv;
}
{
MY_CXT_CLONE;
- MY_CXT.wizz = hv;
- MY_CXT.count = count;
+ MY_CXT = hv;
}
#endif /* VMG_THREADSAFE */
if (SvOK(svsig)) {
SV **old;
sig = vmg_sv2sig(svsig);
- if ((old = hv_fetch(MY_CXT.wizz, buf, sprintf(buf, "%u", sig), 0))) {
+ if ((old = hv_fetch(MY_CXT, buf, sprintf(buf, "%u", sig), 0))) {
ST(0) = sv_2mortal(newRV_inc(*old));
XSRETURN(1);
}
} else {
- if (MY_CXT.count >= SIG_NBR) { croak(vmg_toomanysigs); }
+ if (HvKEYS(MY_CXT) >= SIG_NBR) { croak(vmg_toomanysigs); }
sig = vmg_gensig();
}
mg->mg_private = SIG_WIZ;
SvREADONLY_on(sv);
- hv_store(MY_CXT.wizz, buf, sprintf(buf, "%u", sig), sv, 0);
- ++MY_CXT.count;
+ hv_store(MY_CXT, buf, sprintf(buf, "%u", sig), sv, 0);
RETVAL = newRV_noinc(sv);
OUTPUT:
PROTOTYPE:
CODE:
dMY_CXT;
- if (MY_CXT.count >= SIG_NBR) { croak(vmg_toomanysigs); }
+ if (HvKEYS(MY_CXT) >= SIG_NBR) { croak(vmg_toomanysigs); }
RETVAL = newSVuv(vmg_gensig());
OUTPUT:
RETVAL