I am getting compile warnings on FreeBSD 6.2:
Please specify prototyping behavior for CImpl.xs (see perlxs manual)
CImpl.xs: In function `XS_Cache__FastMmap__CImpl_fc_new':
CImpl.xs:24: warning: cast from pointer to integer of different size
CImpl.xs: In function `XS_Cache__FastMmap__CImpl_fc_set_param':
CImpl.xs:49: warning: cast to pointer from integer of different size
CImpl.xs: In function `XS_Cache__FastMmap__CImpl_fc_init':
CImpl.xs:76: warning: cast to pointer from integer of different size
CImpl.xs: In function `XS_Cache__FastMmap__CImpl_fc_close':
CImpl.xs:104: warning: cast to pointer from integer of different size
CImpl.xs: In function `XS_Cache__FastMmap__CImpl_fc_hash':
CImpl.xs:135: warning: cast to pointer from integer of different size
CImpl.xs: In function `XS_Cache__FastMmap__CImpl_fc_lock':
CImpl.xs:170: warning: cast to pointer from integer of different size
CImpl.xs: In function `XS_Cache__FastMmap__CImpl_fc_unlock':
CImpl.xs:199: warning: cast to pointer from integer of different size
CImpl.xs: In function `XS_Cache__FastMmap__CImpl_fc_read':
CImpl.xs:236: warning: cast to pointer from integer of different size
CImpl.xs: In function `XS_Cache__FastMmap__CImpl_fc_write':
CImpl.xs:303: warning: cast to pointer from integer of different size
CImpl.xs: In function `XS_Cache__FastMmap__CImpl_fc_delete':
CImpl.xs:365: warning: cast to pointer from integer of different size
CImpl.xs: In function `XS_Cache__FastMmap__CImpl_fc_expunge':
CImpl.xs:409: warning: cast to pointer from integer of different size
CImpl.xs: In function `XS_Cache__FastMmap__CImpl_fc_get_keys':
CImpl.xs:490: warning: cast to pointer from integer of different size
CImpl.xs: In function `XS_Cache__FastMmap__CImpl_fc_get':
CImpl.xs:576: warning: cast to pointer from integer of different size
CImpl.xs: In function `XS_Cache__FastMmap__CImpl_fc_set':
CImpl.xs:619: warning: cast to pointer from integer of different size
CImpl.xs:634: warning: cast to pointer from integer of different size
mmap_cache.c: In function `mmc_write':
mmap_cache.c:679: warning: ISO C90 forbids mixed declarations and code
The attached patch fixes these warnings.
See also ticket #31223 which has a similar fix for mmap_cache.c
Subject: | Cache-FastMmap-1.24.tar.gz.fix_warnings.patch |
diff -Naur ../Cache-FastMmap-1.24.orig/Cache-FastMmap-CImpl/CImpl.xs ../Cache-FastMmap-1.24/Cache-FastMmap-CImpl/CImpl.xs
--- ../Cache-FastMmap-1.24.orig/Cache-FastMmap-CImpl/CImpl.xs Tue Oct 16 20:38:49 2007
+++ ../Cache-FastMmap-1.24/Cache-FastMmap-CImpl/CImpl.xs Wed Dec 26 00:17:09 2007
@@ -11,6 +11,7 @@
MODULE = Cache::FastMmap::CImpl PACKAGE = Cache::FastMmap::CImpl
+PROTOTYPES: ENABLE
SV *
fc_new()
@@ -21,7 +22,7 @@
cache = mmc_new();
/* Create integer which is pointer to cache object */
- obj_pnt = newSViv((IV)cache);
+ obj_pnt = newSViv(PTR2IV(cache));
/* Create reference to integer value. This will be the object */
obj = newRV_noinc((SV *)obj_pnt);
@@ -46,7 +47,7 @@
croak("Object not initiliased correctly");
XSRETURN_UNDEF;
}
- cache = (mmap_cache *)SvIV(obj);
+ cache = INT2PTR(mmap_cache *, SvIV(obj) );
if (!cache) {
croak("Object not created correctly");
XSRETURN_UNDEF;
@@ -73,7 +74,7 @@
croak("Object not initiliased correctly");
XSRETURN_UNDEF;
}
- cache = (mmap_cache *)SvIV(obj);
+ cache = INT2PTR(mmap_cache *, SvIV(obj));
if (!cache) {
croak("Object not created correctly");
XSRETURN_UNDEF;
@@ -101,7 +102,7 @@
croak("Object not initiliased correctly");
XSRETURN_UNDEF;
}
- cache = (mmap_cache *)SvIV(obj);
+ cache = INT2PTR(mmap_cache *, SvIV(obj));
if (!cache) {
croak("Object not created correctly");
XSRETURN_UNDEF;
@@ -132,7 +133,7 @@
croak("Object not initiliased correctly");
XSRETURN_UNDEF;
}
- cache = (mmap_cache *)SvIV(obj);
+ cache = INT2PTR(mmap_cache *, SvIV(obj));
if (!cache) {
croak("Object not created correctly");
XSRETURN_UNDEF;
@@ -167,7 +168,7 @@
croak("Object not initiliased correctly");
XSRETURN_UNDEF;
}
- cache = (mmap_cache *)SvIV(obj);
+ cache = INT2PTR(mmap_cache *, SvIV(obj));
if (!cache) {
croak("Object not created correctly");
XSRETURN_UNDEF;
@@ -196,7 +197,7 @@
croak("Object not initiliased correctly");
XSRETURN_UNDEF;
}
- cache = (mmap_cache *)SvIV(obj);
+ cache = INT2PTR(mmap_cache *, SvIV(obj));
if (!cache) {
croak("Object not created correctly");
XSRETURN_UNDEF;
@@ -233,7 +234,7 @@
croak("Object not initiliased correctly");
XSRETURN_UNDEF;
}
- cache = (mmap_cache *)SvIV(obj);
+ cache = INT2PTR(mmap_cache *, SvIV(obj));
if (!cache) {
croak("Object not created correctly");
XSRETURN_UNDEF;
@@ -300,7 +301,7 @@
croak("Object not initiliased correctly");
XSRETURN_UNDEF;
}
- cache = (mmap_cache *)SvIV(obj);
+ cache = INT2PTR(mmap_cache *, SvIV(obj));
if (!cache) {
croak("Object not created correctly");
XSRETURN_UNDEF;
@@ -362,7 +363,7 @@
croak("Object not initiliased correctly");
XSRETURN_UNDEF;
}
- cache = (mmap_cache *)SvIV(obj);
+ cache = INT2PTR(mmap_cache *, SvIV(obj));
if (!cache) {
croak("Object not created correctly");
XSRETURN_UNDEF;
@@ -406,7 +407,7 @@
croak("Object not initiliased correctly");
XSRETURN_UNDEF;
}
- cache = (mmap_cache *)SvIV(obj);
+ cache = INT2PTR(mmap_cache *, SvIV(obj));
if (!cache) {
croak("Object not created correctly");
XSRETURN_UNDEF;
@@ -487,7 +488,7 @@
croak("Object not initiliased correctly");
XSRETURN_UNDEF;
}
- cache = (mmap_cache *)SvIV(obj);
+ cache = INT2PTR(mmap_cache *, SvIV(obj));
if (!cache) {
croak("Object not created correctly");
XSRETURN_UNDEF;
@@ -573,7 +574,7 @@
croak("Object not initiliased correctly");
XSRETURN_UNDEF;
}
- cache = (mmap_cache *)SvIV(obj);
+ cache = INT2PTR(mmap_cache *, SvIV(obj));
if (!cache) {
croak("Object not created correctly");
XSRETURN_UNDEF;
@@ -616,7 +617,7 @@
SV * key;
SV * val;
INIT:
- mmap_cache * cache = (mmap_cache *)SvIV(SvRV(obj));
+ mmap_cache * cache = INT2PTR(mmap_cache *, SvIV(SvRV(obj)));
int key_len, val_len, found;
void * key_ptr, * val_ptr;
MU32 hash_page, hash_slot, flags = 0;
@@ -631,7 +632,7 @@
croak("Object not initiliased correctly");
XSRETURN_UNDEF;
}
- cache = (mmap_cache *)SvIV(obj);
+ cache = INT2PTR(mmap_cache *, SvIV(obj));
if (!cache) {
croak("Object not created correctly");
XSRETURN_UNDEF;
diff -Naur ../Cache-FastMmap-1.24.orig/Cache-FastMmap-CImpl/mmap_cache.c ../Cache-FastMmap-1.24/Cache-FastMmap-CImpl/mmap_cache.c
--- ../Cache-FastMmap-1.24.orig/Cache-FastMmap-CImpl/mmap_cache.c Tue Oct 16 20:05:33 2007
+++ ../Cache-FastMmap-1.24/Cache-FastMmap-CImpl/mmap_cache.c Wed Dec 26 00:02:16 2007
@@ -673,10 +673,11 @@
if (cache->p_free_bytes >= kvlen) {
MU32 * base_det = PTR_ADD(cache->p_base, cache->p_free_data);
MU32 now = (MU32)time(0);
+ MU32 expire_time = 0;
/* Calculate expiry time */
if (expire_seconds == (MU32)-1) expire_seconds = cache->expire_time;
- MU32 expire_time = expire_seconds ? now + expire_seconds : 0;
+ expire_time = expire_seconds ? now + expire_seconds : 0;
/* Store info into slot */
S_LastAccess(base_det) = now;