From: Richard Soderberg Date: Mon, 29 Oct 2001 17:01:10 +0000 (-0800) Subject: Mommy, what's a pointer cast? X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=170958c3858be28fa763f2ead791ca13b71d46dd;p=p5sagit%2Fp5-mst-13.2.git Mommy, what's a pointer cast? Message-Id: <200110300101.RAA31561@oregonnet.com> (threads* parts) p4raw-id: //depot/perl@12773 --- diff --git a/ext/threads/shared/shared.xs b/ext/threads/shared/shared.xs index 2eb2e6c..92e24d4 100644 --- a/ext/threads/shared/shared.xs +++ b/ext/threads/shared/shared.xs @@ -7,7 +7,7 @@ MGVTBL svtable; SV* shared_sv_attach_sv (SV* sv, shared_sv* shared) { HV* shared_hv = get_hv("threads::shared::shared", FALSE); - SV* id = newSViv((IV)shared); + SV* id = newSViv(PTR2IV(shared)); STRLEN length = sv_len(id); SV* tiedobject; SV** tiedobject_ = hv_fetch(shared_hv, SvPV(id,length), length, 0); @@ -26,7 +26,7 @@ SV* shared_sv_attach_sv (SV* sv, shared_sv* shared) { SV* obj_ref = newSViv(0); SV* obj = newSVrv(obj_ref,"threads::shared::av"); AV* hv = newAV(); - sv_setiv(obj,(IV)shared); + sv_setiv(obj,PTR2IV(shared)); weakref = newRV((SV*)hv); sv = newRV_noinc((SV*)hv); sv_rvweaken(weakref); @@ -40,7 +40,7 @@ SV* shared_sv_attach_sv (SV* sv, shared_sv* shared) { SV* obj_ref = newSViv(0); SV* obj = newSVrv(obj_ref,"threads::shared::hv"); HV* hv = newHV(); - sv_setiv(obj,(IV)shared); + sv_setiv(obj,PTR2IV(shared)); weakref = newRV((SV*)hv); sv = newRV_noinc((SV*)hv); sv_rvweaken(weakref); @@ -52,11 +52,11 @@ SV* shared_sv_attach_sv (SV* sv, shared_sv* shared) { default: { MAGIC* shared_magic; SV* value = newSVsv(SHAREDSvGET(shared)); - SV* obj = newSViv((IV)shared); + SV* obj = newSViv(PTR2IV(shared)); sv_magic(value, 0, PERL_MAGIC_ext, "threads::shared", 16); shared_magic = mg_find(value, PERL_MAGIC_ext); shared_magic->mg_virtual = &svtable; - shared_magic->mg_obj = newSViv((IV)shared); + shared_magic->mg_obj = newSViv(PTR2IV(shared)); shared_magic->mg_flags |= MGf_REFCOUNTED; shared_magic->mg_private = 0; SvMAGICAL_on(value); @@ -74,11 +74,11 @@ SV* shared_sv_attach_sv (SV* sv, shared_sv* shared) { int shared_sv_fetch_mg (pTHX_ SV* sv, MAGIC *mg) { - shared_sv* shared = (shared_sv*) SvIV(mg->mg_obj); + shared_sv* shared = INT2PTR(shared_sv*, SvIV(mg->mg_obj)); SHAREDSvLOCK(shared); if(mg->mg_private != shared->index) { if(SvROK(SHAREDSvGET(shared))) { - shared_sv* target = (shared_sv*) SvIV(SvRV(SHAREDSvGET(shared))); + shared_sv* target = INT2PTR(shared_sv*, SvIV(SvRV(SHAREDSvGET(shared)))); shared_sv_attach_sv(sv, target); } else { sv_setsv(sv, SHAREDSvGET(shared)); @@ -91,10 +91,10 @@ int shared_sv_fetch_mg (pTHX_ SV* sv, MAGIC *mg) { } int shared_sv_store_mg (pTHX_ SV* sv, MAGIC *mg) { - shared_sv* shared = (shared_sv*) SvIV(mg->mg_obj); + shared_sv* shared = INT2PTR(shared_sv*, SvIV(mg->mg_obj)); SHAREDSvLOCK(shared); if(SvROK(SHAREDSvGET(shared))) - Perl_sharedsv_thrcnt_dec(aTHX_ (shared_sv*) SvIV(SvRV(SHAREDSvGET(shared)))); + Perl_sharedsv_thrcnt_dec(aTHX_ INT2PTR(shared_sv*, SvIV(SvRV(SHAREDSvGET(shared))))); if(SvROK(sv)) { shared_sv* target = Perl_sharedsv_find(aTHX_ SvRV(sv)); if(!target) { @@ -104,7 +104,7 @@ int shared_sv_store_mg (pTHX_ SV* sv, MAGIC *mg) { } SHAREDSvEDIT(shared); Perl_sv_free(PL_sharedsv_space,SHAREDSvGET(shared)); - SHAREDSvGET(shared) = newRV_noinc(newSViv((IV)target)); + SHAREDSvGET(shared) = newRV_noinc(newSViv(PTR2IV(target))); } else { SHAREDSvEDIT(shared); sv_setsv(SHAREDSvGET(shared), sv); @@ -113,18 +113,18 @@ int shared_sv_store_mg (pTHX_ SV* sv, MAGIC *mg) { mg->mg_private = shared->index; SHAREDSvRELEASE(shared); if(SvROK(SHAREDSvGET(shared))) - Perl_sharedsv_thrcnt_inc(aTHX_ (shared_sv*) SvIV(SvRV(SHAREDSvGET(shared)))); + Perl_sharedsv_thrcnt_inc(aTHX_ INT2PTR(shared_sv*, SvIV(SvRV(SHAREDSvGET(shared))))); SHAREDSvUNLOCK(shared); return 0; } int shared_sv_destroy_mg (pTHX_ SV* sv, MAGIC *mg) { - shared_sv* shared = (shared_sv*) SvIV(mg->mg_obj); + shared_sv* shared = INT2PTR(shared_sv*, SvIV(mg->mg_obj)); if(!shared) return 0; { HV* shared_hv = get_hv("threads::shared::shared", FALSE); - SV* id = newSViv((IV)shared); + SV* id = newSViv(PTR2IV(shared)); STRLEN length = sv_len(id); hv_delete(shared_hv, SvPV(id,length), length,0); } @@ -176,7 +176,7 @@ thrcnt_inc(ref,perl) SV* perl CODE: shared_sv* shared; - PerlInterpreter* origperl = (PerlInterpreter*) SvIV(perl); + PerlInterpreter* origperl = INT2PTR(PerlInterpreter*, SvIV(perl)); PerlInterpreter* oldperl = PERL_GET_CONTEXT; if(SvROK(ref)) ref = SvRV(ref); @@ -191,7 +191,7 @@ void _thrcnt_dec(ref) SV* ref CODE: - shared_sv* shared = (shared_sv*) SvIV(ref); + shared_sv* shared = INT2PTR(shared_sv*, SvIV(ref)); if(!shared) croak("thrcnt can only be used on shared values"); Perl_sharedsv_thrcnt_dec(aTHX_ shared); @@ -278,14 +278,14 @@ new(class, value) CODE: shared_sv* shared = Perl_sharedsv_new(aTHX); MAGIC* shared_magic; - SV* obj = newSViv((IV)shared); + SV* obj = newSViv(PTR2IV(shared)); SHAREDSvEDIT(shared); SHAREDSvGET(shared) = newSVsv(value); SHAREDSvRELEASE(shared); sv_magic(value, 0, PERL_MAGIC_ext, "threads::shared", 16); shared_magic = mg_find(value, PERL_MAGIC_ext); shared_magic->mg_virtual = &svtable; - shared_magic->mg_obj = newSViv((IV)shared); + shared_magic->mg_obj = newSViv(PTR2IV(shared)); shared_magic->mg_flags |= MGf_REFCOUNTED; shared_magic->mg_private = 0; SvMAGICAL_on(value); @@ -302,7 +302,7 @@ new(class, value) SV* value CODE: shared_sv* shared = Perl_sharedsv_new(aTHX); - SV* obj = newSViv((IV)shared); + SV* obj = newSViv(PTR2IV(shared)); SHAREDSvEDIT(shared); SHAREDSvGET(shared) = (SV*) newAV(); SHAREDSvRELEASE(shared); @@ -316,7 +316,7 @@ STORE(self, index, value) SV* index SV* value CODE: - shared_sv* shared = (shared_sv*) SvIV(SvRV(self)); + shared_sv* shared = INT2PTR(shared_sv*, SvIV(SvRV(self))); shared_sv* slot; SV* aentry; SV** aentry_; @@ -325,15 +325,15 @@ STORE(self, index, value) if(!target) { Perl_croak(aTHX_ "You cannot assign a non shared reference to an shared array"); } - value = newRV_noinc(newSViv((IV)target)); + value = newRV_noinc(newSViv(PTR2IV(target))); } SHAREDSvLOCK(shared); aentry_ = av_fetch((AV*) SHAREDSvGET(shared), SvIV(index), 0); if(aentry_ && SvIV((*aentry_))) { aentry = (*aentry_); - slot = (shared_sv*) SvIV(aentry); + slot = INT2PTR(shared_sv*, SvIV(aentry)); if(SvROK(SHAREDSvGET(slot))) - Perl_sharedsv_thrcnt_dec(aTHX_ (shared_sv*) SvIV(SvRV(SHAREDSvGET(slot)))); + Perl_sharedsv_thrcnt_dec(aTHX_ INT2PTR(shared_sv*, SvIV(SvRV(SHAREDSvGET(slot))))); SHAREDSvEDIT(slot); sv_setsv(SHAREDSvGET(slot), value); SHAREDSvRELEASE(slot); @@ -341,12 +341,12 @@ STORE(self, index, value) slot = Perl_sharedsv_new(aTHX); SHAREDSvEDIT(shared); SHAREDSvGET(slot) = newSVsv(value); - aentry = newSViv((IV)slot); + aentry = newSViv(PTR2IV(slot)); av_store((AV*) SHAREDSvGET(shared), SvIV(index), aentry); SHAREDSvRELEASE(shared); } if(SvROK(SHAREDSvGET(slot))) - Perl_sharedsv_thrcnt_inc(aTHX_ (shared_sv*) SvIV(SvRV(SHAREDSvGET(slot)))); + Perl_sharedsv_thrcnt_inc(aTHX_ INT2PTR(shared_sv*, SvIV(SvRV(SHAREDSvGET(slot))))); SHAREDSvUNLOCK(shared); @@ -355,7 +355,7 @@ FETCH(self, index) SV* self SV* index CODE: - shared_sv* shared = (shared_sv*) SvIV(SvRV(self)); + shared_sv* shared = INT2PTR(shared_sv*, SvIV(SvRV(self))); shared_sv* slot; SV* aentry; SV** aentry_; @@ -367,9 +367,9 @@ FETCH(self, index) if(SvTYPE(aentry) == SVt_NULL) { retval = &PL_sv_undef; } else { - slot = (shared_sv*) SvIV(aentry); + slot = INT2PTR(shared_sv*, SvIV(aentry)); if(SvROK(SHAREDSvGET(slot))) { - shared_sv* target = (shared_sv*) SvIV(SvRV(SHAREDSvGET(slot))); + shared_sv* target = INT2PTR(shared_sv*, SvIV(SvRV(SHAREDSvGET(slot)))); retval = shared_sv_attach_sv(NULL,target); } else { retval = newSVsv(SHAREDSvGET(slot)); @@ -387,7 +387,7 @@ void PUSH(self, ...) SV* self CODE: - shared_sv* shared = (shared_sv*) SvIV(SvRV(self)); + shared_sv* shared = INT2PTR(shared_sv*, SvIV(SvRV(self))); int i; SHAREDSvLOCK(shared); for(i = 1; i < items; i++) { @@ -398,14 +398,14 @@ PUSH(self, ...) if(!target) { Perl_croak(aTHX_ "You cannot assign a non shared reference to an shared array"); } - tmp = newRV_noinc(newSViv((IV)target)); + tmp = newRV_noinc(newSViv(PTR2IV(target))); } SHAREDSvEDIT(slot); SHAREDSvGET(slot) = newSVsv(tmp); - av_push((AV*) SHAREDSvGET(shared), newSViv((IV)slot)); + av_push((AV*) SHAREDSvGET(shared), newSViv(PTR2IV(slot))); SHAREDSvRELEASE(slot); if(SvROK(SHAREDSvGET(slot))) - Perl_sharedsv_thrcnt_inc(aTHX_ (shared_sv*) SvIV(SvRV(SHAREDSvGET(slot)))); + Perl_sharedsv_thrcnt_inc(aTHX_ INT2PTR(shared_sv*, SvIV(SvRV(SHAREDSvGET(slot))))); } SHAREDSvUNLOCK(shared); @@ -413,7 +413,7 @@ void UNSHIFT(self, ...) SV* self CODE: - shared_sv* shared = (shared_sv*) SvIV(SvRV(self)); + shared_sv* shared = INT2PTR(shared_sv*, SvIV(SvRV(self))); int i; SHAREDSvLOCK(shared); SHAREDSvEDIT(shared); @@ -427,14 +427,14 @@ UNSHIFT(self, ...) if(!target) { Perl_croak(aTHX_ "You cannot assign a non shared reference to an shared array"); } - tmp = newRV_noinc(newSViv((IV)target)); + tmp = newRV_noinc(newSViv(PTR2IV(target))); } SHAREDSvEDIT(slot); SHAREDSvGET(slot) = newSVsv(tmp); - av_store((AV*) SHAREDSvGET(shared), i - 1, newSViv((IV)slot)); + av_store((AV*) SHAREDSvGET(shared), i - 1, newSViv(PTR2IV(slot))); SHAREDSvRELEASE(slot); if(SvROK(SHAREDSvGET(slot))) - Perl_sharedsv_thrcnt_inc(aTHX_ (shared_sv*) SvIV(SvRV(SHAREDSvGET(slot)))); + Perl_sharedsv_thrcnt_inc(aTHX_ INT2PTR(shared_sv*, SvIV(SvRV(SHAREDSvGET(slot))))); } SHAREDSvUNLOCK(shared); @@ -442,7 +442,7 @@ SV* POP(self) SV* self CODE: - shared_sv* shared = (shared_sv*) SvIV(SvRV(self)); + shared_sv* shared = INT2PTR(shared_sv*, SvIV(SvRV(self))); shared_sv* slot; SV* retval; SHAREDSvLOCK(shared); @@ -450,9 +450,9 @@ POP(self) retval = av_pop((AV*)SHAREDSvGET(shared)); SHAREDSvRELEASE(shared); if(retval && SvIV(retval)) { - slot = (shared_sv*) SvIV(retval); + slot = INT2PTR(shared_sv*, SvIV(retval)); if(SvROK(SHAREDSvGET(slot))) { - shared_sv* target = (shared_sv*) SvIV(SvRV(SHAREDSvGET(slot))); + shared_sv* target = INT2PTR(shared_sv*, SvIV(SvRV(SHAREDSvGET(slot)))); retval = shared_sv_attach_sv(NULL,target); } else { retval = newSVsv(SHAREDSvGET(slot)); @@ -471,7 +471,7 @@ SV* SHIFT(self) SV* self CODE: - shared_sv* shared = (shared_sv*) SvIV(SvRV(self)); + shared_sv* shared = INT2PTR(shared_sv*, SvIV(SvRV(self))); shared_sv* slot; SV* retval; SHAREDSvLOCK(shared); @@ -479,9 +479,9 @@ SHIFT(self) retval = av_shift((AV*)SHAREDSvGET(shared)); SHAREDSvRELEASE(shared); if(retval && SvIV(retval)) { - slot = (shared_sv*) SvIV(retval); + slot = INT2PTR(shared_sv*, SvIV(retval)); if(SvROK(SHAREDSvGET(slot))) { - shared_sv* target = (shared_sv*) SvIV(SvRV(SHAREDSvGET(slot))); + shared_sv* target = INT2PTR(shared_sv*, SvIV(SvRV(SHAREDSvGET(slot)))); retval = shared_sv_attach_sv(NULL,target); } else { retval = newSVsv(SHAREDSvGET(slot)); @@ -499,7 +499,7 @@ void CLEAR(self) SV* self CODE: - shared_sv* shared = (shared_sv*) SvIV(SvRV(self)); + shared_sv* shared = INT2PTR(shared_sv*, SvIV(SvRV(self))); shared_sv* slot; SV** svp; I32 i; @@ -508,7 +508,7 @@ CLEAR(self) i = AvFILLp((AV*)SHAREDSvGET(shared)); while ( i >= 0) { if(SvIV(svp[i])) { - Perl_sharedsv_thrcnt_dec(aTHX_ (shared_sv*) SvIV(svp[i])); + Perl_sharedsv_thrcnt_dec(aTHX_ INT2PTR(shared_sv*, SvIV(svp[i]))); } i--; } @@ -522,7 +522,7 @@ EXTEND(self, count) SV* self SV* count CODE: - shared_sv* shared = (shared_sv*) SvIV(SvRV(self)); + shared_sv* shared = INT2PTR(shared_sv*, SvIV(SvRV(self))); SHAREDSvEDIT(shared); av_extend((AV*)SHAREDSvGET(shared), (I32) SvIV(count)); SHAREDSvRELEASE(shared); @@ -535,7 +535,7 @@ EXISTS(self, index) SV* self SV* index CODE: - shared_sv* shared = (shared_sv*) SvIV(SvRV(self)); + shared_sv* shared = INT2PTR(shared_sv*, SvIV(SvRV(self))); I32 exists; SHAREDSvLOCK(shared); exists = av_exists((AV*) SHAREDSvGET(shared), (I32) SvIV(index)); @@ -551,7 +551,7 @@ STORESIZE(self,count) SV* self SV* count CODE: - shared_sv* shared = (shared_sv*) SvIV(SvRV(self)); + shared_sv* shared = INT2PTR(shared_sv*, SvIV(SvRV(self))); SHAREDSvEDIT(shared); av_fill((AV*) SHAREDSvGET(shared), (I32) SvIV(count)); SHAREDSvRELEASE(shared); @@ -560,7 +560,7 @@ SV* FETCHSIZE(self) SV* self CODE: - shared_sv* shared = (shared_sv*) SvIV(SvRV(self)); + shared_sv* shared = INT2PTR(shared_sv*, SvIV(SvRV(self))); SHAREDSvLOCK(shared); RETVAL = newSViv(av_len((AV*) SHAREDSvGET(shared)) + 1); SHAREDSvUNLOCK(shared); @@ -572,7 +572,7 @@ DELETE(self,index) SV* self SV* index CODE: - shared_sv* shared = (shared_sv*) SvIV(SvRV(self)); + shared_sv* shared = INT2PTR(shared_sv*, SvIV(SvRV(self))); shared_sv* slot; SHAREDSvLOCK(shared); if(av_exists((AV*) SHAREDSvGET(shared), (I32) SvIV(index))) { @@ -581,9 +581,9 @@ DELETE(self,index) tmp = av_delete((AV*)SHAREDSvGET(shared), (I32) SvIV(index),0); SHAREDSvRELEASE(shared); if(SvIV(tmp)) { - slot = (shared_sv*) SvIV(tmp); + slot = INT2PTR(shared_sv*, SvIV(tmp)); if(SvROK(SHAREDSvGET(slot))) { - shared_sv* target = (shared_sv*) SvIV(SvRV(SHAREDSvGET(slot))); + shared_sv* target = INT2PTR(shared_sv*, SvIV(SvRV(SHAREDSvGET(slot)))); RETVAL = shared_sv_attach_sv(NULL,target); } else { RETVAL = newSVsv(SHAREDSvGET(slot)); @@ -615,7 +615,7 @@ new(class, value) SV* value CODE: shared_sv* shared = Perl_sharedsv_new(aTHX); - SV* obj = newSViv((IV)shared); + SV* obj = newSViv(PTR2IV(shared)); SHAREDSvEDIT(shared); SHAREDSvGET(shared) = (SV*) newHV(); SHAREDSvRELEASE(shared); @@ -629,7 +629,7 @@ STORE(self, key, value) SV* key SV* value CODE: - shared_sv* shared = (shared_sv*) SvIV(SvRV(self)); + shared_sv* shared = INT2PTR(shared_sv*, SvIV(SvRV(self))); shared_sv* slot; SV* hentry; SV** hentry_; @@ -642,15 +642,15 @@ STORE(self, key, value) Perl_croak(aTHX_ "You cannot assign a non shared reference to a shared hash"); } SHAREDSvEDIT(shared); - value = newRV_noinc(newSViv((IV)target)); + value = newRV_noinc(newSViv(PTR2IV(target))); SHAREDSvRELEASE(shared); } hentry_ = hv_fetch((HV*) SHAREDSvGET(shared), ckey, len, 0); if(hentry_ && SvIV((*hentry_))) { hentry = (*hentry_); - slot = (shared_sv*) SvIV(hentry); + slot = INT2PTR(shared_sv*, SvIV(hentry)); if(SvROK(SHAREDSvGET(slot))) - Perl_sharedsv_thrcnt_dec(aTHX_ (shared_sv*) SvIV(SvRV(SHAREDSvGET(slot)))); + Perl_sharedsv_thrcnt_dec(aTHX_ INT2PTR(shared_sv*, SvIV(SvRV(SHAREDSvGET(slot))))); SHAREDSvEDIT(slot); sv_setsv(SHAREDSvGET(slot), value); SHAREDSvRELEASE(slot); @@ -658,12 +658,12 @@ STORE(self, key, value) slot = Perl_sharedsv_new(aTHX); SHAREDSvEDIT(shared); SHAREDSvGET(slot) = newSVsv(value); - hentry = newSViv((IV)slot); + hentry = newSViv(PTR2IV(slot)); hv_store((HV*) SHAREDSvGET(shared), ckey,len , hentry, 0); SHAREDSvRELEASE(shared); } if(SvROK(SHAREDSvGET(slot))) - Perl_sharedsv_thrcnt_inc(aTHX_ (shared_sv*) SvIV(SvRV(SHAREDSvGET(slot)))); + Perl_sharedsv_thrcnt_inc(aTHX_ INT2PTR(shared_sv*, SvIV(SvRV(SHAREDSvGET(slot))))); SHAREDSvUNLOCK(shared); @@ -672,7 +672,7 @@ FETCH(self, key) SV* self SV* key CODE: - shared_sv* shared = (shared_sv*) SvIV(SvRV(self)); + shared_sv* shared = INT2PTR(shared_sv*, SvIV(SvRV(self))); shared_sv* slot; SV* hentry; SV** hentry_; @@ -686,9 +686,9 @@ FETCH(self, key) if(SvTYPE(hentry) == SVt_NULL) { retval = &PL_sv_undef; } else { - slot = (shared_sv*) SvIV(hentry); + slot = INT2PTR(shared_sv*, SvIV(hentry)); if(SvROK(SHAREDSvGET(slot))) { - shared_sv* target = (shared_sv*) SvIV(SvRV(SHAREDSvGET(slot))); + shared_sv* target = INT2PTR(shared_sv*, SvIV(SvRV(SHAREDSvGET(slot)))); retval = shared_sv_attach_sv(NULL, target); } else { retval = newSVsv(SHAREDSvGET(slot)); @@ -706,14 +706,14 @@ void CLEAR(self) SV* self CODE: - shared_sv* shared = (shared_sv*) SvIV(SvRV(self)); + shared_sv* shared = INT2PTR(shared_sv*, SvIV(SvRV(self))); shared_sv* slot; HE* entry; SHAREDSvLOCK(shared); Perl_hv_iterinit(PL_sharedsv_space, (HV*) SHAREDSvGET(shared)); entry = Perl_hv_iternext(PL_sharedsv_space, (HV*) SHAREDSvGET(shared)); while(entry) { - slot = (shared_sv*) SvIV(Perl_hv_iterval(PL_sharedsv_space, (HV*) SHAREDSvGET(shared), entry)); + slot = INT2PTR(shared_sv*, SvIV(Perl_hv_iterval(PL_sharedsv_space, (HV*) SHAREDSvGET(shared), entry))); Perl_sharedsv_thrcnt_dec(aTHX_ slot); entry = Perl_hv_iternext(PL_sharedsv_space,(HV*) SHAREDSvGET(shared)); } @@ -726,7 +726,7 @@ SV* FIRSTKEY(self) SV* self CODE: - shared_sv* shared = (shared_sv*) SvIV(SvRV(self)); + shared_sv* shared = INT2PTR(shared_sv*, SvIV(SvRV(self))); char* key = NULL; I32 len; HE* entry; @@ -749,7 +749,7 @@ NEXTKEY(self, oldkey) SV* self SV* oldkey CODE: - shared_sv* shared = (shared_sv*) SvIV(SvRV(self)); + shared_sv* shared = INT2PTR(shared_sv*, SvIV(SvRV(self))); char* key = NULL; I32 len; HE* entry; @@ -771,7 +771,7 @@ EXISTS(self, key) SV* self SV* key CODE: - shared_sv* shared = (shared_sv*) SvIV(SvRV(self)); + shared_sv* shared = INT2PTR(shared_sv*, SvIV(SvRV(self))); STRLEN len; char* ckey = SvPV(key, len); SHAREDSvLOCK(shared); @@ -789,7 +789,7 @@ DELETE(self, key) SV* self SV* key CODE: - shared_sv* shared = (shared_sv*) SvIV(SvRV(self)); + shared_sv* shared = INT2PTR(shared_sv*, SvIV(SvRV(self))); shared_sv* slot; STRLEN len; char* ckey = SvPV(key, len); @@ -799,9 +799,9 @@ DELETE(self, key) tmp = hv_delete((HV*) SHAREDSvGET(shared), ckey, len,0); SHAREDSvRELEASE(shared); if(tmp) { - slot = (shared_sv*) SvIV(tmp); + slot = INT2PTR(shared_sv*, SvIV(tmp)); if(SvROK(SHAREDSvGET(slot))) { - shared_sv* target = (shared_sv*) SvIV(SvRV(SHAREDSvGET(slot))); + shared_sv* target = INT2PTR(shared_sv*, SvIV(SvRV(SHAREDSvGET(slot)))); RETVAL = shared_sv_attach_sv(NULL, target); } else { RETVAL = newSVsv(SHAREDSvGET(slot)); diff --git a/ext/threads/threads.xs b/ext/threads/threads.xs index 75a6b0b..1ff565e 100755 --- a/ext/threads/threads.xs +++ b/ext/threads/threads.xs @@ -88,7 +88,7 @@ SV* Perl_thread_create(char* class, SV* init_function, SV* params) { MUTEX_LOCK(&create_mutex); obj_ref = newSViv(0); obj = newSVrv(obj_ref, class); - sv_setiv(obj, (IV)thread); + sv_setiv(obj, PTR2IV(thread)); SvREADONLY_on(obj); PerlIO_flush((PerlIO*)NULL); current_perl = PERL_GET_CONTEXT; @@ -112,7 +112,7 @@ SV* Perl_thread_create(char* class, SV* init_function, SV* params) { temp_store = NULL; temp_store = Perl_get_sv(current_perl, "threads::origthread", TRUE | GV_ADDMULTI); - sv_setiv(temp_store,(IV)current_perl); + sv_setiv(temp_store,PTR2IV(current_perl)); temp_store = NULL; @@ -198,10 +198,10 @@ I32 Perl_thread_tid (SV* obj) { ithread* thread; if(!SvROK(obj)) { obj = Perl_thread_self(SvPV_nolen(obj)); - thread = (ithread*)SvIV(SvRV(obj)); + thread = INT2PTR(ithread*, SvIV(SvRV(obj))); SvREFCNT_dec(obj); } else { - thread = (ithread*)SvIV(SvRV(obj)); + thread = INT2PTR(ithread*, SvIV(SvRV(obj))); } return thread->tid; } @@ -240,7 +240,7 @@ SV* Perl_thread_self (char* class) { * call_sv and send it back */ void Perl_thread_join(SV* obj) { - ithread* thread = (ithread*)SvIV(SvRV(obj)); + ithread* thread = INT2PTR(ithread*, SvIV(SvRV(obj))); #ifdef WIN32 DWORD waitcode; waitcode = WaitForSingleObject(thread->handle, INFINITE); @@ -254,7 +254,7 @@ void Perl_thread_join(SV* obj) { * needs to better clean up memory */ void Perl_thread_detach(SV* obj) { - ithread* thread = (ithread*)SvIV(SvRV(obj)); + ithread* thread = INT2PTR(ithread*, SvIV(SvRV(obj))); MUTEX_LOCK(&thread->mutex); thread->detached = 1; PERL_THREAD_DETACH(thread->thr); @@ -262,7 +262,7 @@ void Perl_thread_detach(SV* obj) { } void Perl_thread_DESTROY (SV* obj) { - ithread* thread = (ithread*)SvIV(SvRV(obj)); + ithread* thread = INT2PTR(ithread*, SvIV(SvRV(obj))); MUTEX_LOCK(&thread->mutex); thread->count--; @@ -295,7 +295,7 @@ BOOT: SV* temp = get_sv("threads::sharedsv_space", TRUE | GV_ADDMULTI); - SV* temp2 = newSViv((IV)PL_sharedsv_space ); + SV* temp2 = newSViv(PTR2IV(PL_sharedsv_space)); sv_setsv( temp , temp2 ); } {