develooper Front page | perl.perl5.porters | Postings from October 2001

[PATCH] Mommy, what's a pointer cast?

Thread Next
From:
Richard Soderberg
Date:
October 29, 2001 17:01
Subject:
[PATCH] Mommy, what's a pointer cast?
Message ID:
200110300101.RAA31561@oregonnet.com
dlutils.c: In function `dl_generic_private_init':
dlutils.c:87: warning: cast from pointer to integer of different size
dlutils.c: In function `saveError':
dlutils.c:118: warning: cast to pointer from integer of different size

I hate those warnings.  Fixed them all, the ones in my_cxt_sv and all
hundred of the ones in threads/*.  Bleh.

After this set of patches (and my previous signal warnings patch),
perl compiles on OpenBSD 2.9 with a *single* warning.

pp_sys.c:281: warning: _emulate_eaccess' defined but not used

Which appears to have some comments screaming about "we can't fix this."

YAY programs that compile cleanly, start to finish.  :)

R.

--- ../perl-clean/perl.h	Fri Oct 26 10:45:13 2001
+++ perl.h	Mon Oct 29 18:09:36 2001
@@ -3815,7 +3815,7 @@
  * interpreter-local data. */
 #define dMY_CXT	\
 	dMY_CXT_SV;							\
-	my_cxt_t *my_cxtp = (my_cxt_t*)SvUV(my_cxt_sv)
+	my_cxt_t *my_cxtp = INT2PTR(my_cxt_t*, SvUV(my_cxt_sv))
 
 /* Creates and zeroes the per-interpreter data.
  * (We allocate my_cxtp in a Perl SV so that it will be released when
@@ -3825,7 +3825,7 @@
 	/* newSV() allocates one more than needed */			\
 	my_cxt_t *my_cxtp = (my_cxt_t*)SvPVX(newSV(sizeof(my_cxt_t)-1));\
 	Zero(my_cxtp, 1, my_cxt_t);					\
-	sv_setuv(my_cxt_sv, (UV)my_cxtp)
+	sv_setuv(my_cxt_sv, PTR2UV(my_cxtp))
 
 /* This macro must be used to access members of the my_cxt_t structure.
  * e.g. MYCXT.some_data */
--- ../perl-clean/ext/threads/threads.xs	Mon Oct 29 09:00:25 2001
+++ ext/threads/threads.xs	Mon Oct 29 18:55:41 2001
@@ -88,7 +88,7 @@
 	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 @@
 	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 @@
 	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 @@
  * 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 @@
  * 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_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 @@
 	    
 	
 	    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 );
 	}
 	{
--- ../perl-clean/ext/threads/shared/shared.xs	Mon Oct 29 09:00:25 2001
+++ ext/threads/shared/shared.xs	Mon Oct 29 19:52:18 2001
@@ -7,7 +7,7 @@
 
 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* 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* 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 @@
 	    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 @@
 
 
 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_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 @@
         }
         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 @@
     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 @@
 	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 @@
 _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 @@
 	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 @@
 	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 @@
 	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 @@
 	    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 @@
             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 @@
         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 @@
             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 @@
 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 @@
                  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 @@
 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 @@
                  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 @@
 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 @@
 	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 @@
 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 @@
 	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 @@
 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 @@
 	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 @@
 	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 @@
 	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 @@
 	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 @@
 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 @@
 	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 @@
 	    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 @@
 	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 @@
         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 @@
 		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 @@
             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 @@
         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 @@
             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 @@
 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 @@
 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 @@
         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 @@
 	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 @@
         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 @@
 	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));

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About