Subject: | building Compress-Snappy on Solaris with Sun Studio |
Date: | Thu, 1 Dec 2011 10:46:30 +1100 |
To: | gray [...] cpan.org, bug-Compress-Snappy [...] rt.cpan.org |
From: | Brad Forschinger <bnjf [...] bnjf.id.au> |
Hi,
cc barfs with -Wall, and sizeof()ing a void looks like it only works
in gcc. Here's a diff:
<diff>
diff -ur Compress-Snappy-0.12/Makefile.PL Compress-Snappy-0.12-bnjf/Makefile.PL
--- Compress-Snappy-0.12/Makefile.PL 2011-04-18 19:40:30.000000000 +1000
+++ Compress-Snappy-0.12-bnjf/Makefile.PL 2011-12-01
10:18:55.808795000 +1100
@@ -19,7 +19,7 @@
},
},
- CCFLAGS => '-Wall',
+ #CCFLAGS => '-Wall',
DEFINE => pack('L', 1) ne pack('N', 1)
? '-D__LITTLE_ENDIAN' : '-D__BIG_ENDIAN',
diff -ur Compress-Snappy-0.12/Snappy.xs Compress-Snappy-0.12-bnjf/Snappy.xs
--- Compress-Snappy-0.12/Snappy.xs 2011-04-20 13:42:20.000000000 +1000
+++ Compress-Snappy-0.12-bnjf/Snappy.xs 2011-12-01 10:38:02.622454000 +1100
@@ -30,7 +30,7 @@
max_compressed_len = csnappy_max_compressed_length(len);
RETVAL = newSV(max_compressed_len);
if (! RETVAL) XSRETURN_UNDEF;
- Newx(working_memory, CSNAPPY_WORKMEM_BYTES, void);
+ Newx(working_memory, CSNAPPY_WORKMEM_BYTES, char);
if (! working_memory) XSRETURN_UNDEF;
csnappy_compress(str, len, SvPVX(RETVAL), &compressed_len,
working_memory, CSNAPPY_WORKMEM_BYTES_POWER_OF_TWO);
diff -ur Compress-Snappy-0.12/ppport.h Compress-Snappy-0.12-bnjf/ppport.h
--- Compress-Snappy-0.12/ppport.h 2011-04-11 07:07:38.000000000 +1000
+++ Compress-Snappy-0.12-bnjf/ppport.h 2011-12-01 10:35:57.160513000 +1100
@@ -3125,3 +3125,6 @@
#endif
#endif
#endif
+#if (!defined(_GNUC) || __GNUC_ < 3) && (!defined(_IBMC) || __IBMC_ < 900)
+#define __builtin_expect(x, y) x
+#endif
diff -ur Compress-Snappy-0.12/src/csnappy_internal_userspace.h
Compress-Snappy-0.12-bnjf/src/csnappy_internal_userspace.h
--- Compress-Snappy-0.12/src/csnappy_internal_userspace.h
2011-04-30 05:21:44.000000000 +1000
+++ Compress-Snappy-0.12-bnjf/src/csnappy_internal_userspace.h
2011-12-01 10:28:56.092213000 +1100
@@ -162,6 +162,11 @@
#define bswap_16(x) OSSwapInt16(x)
#define bswap_32(x) OSSwapInt32(x)
#define bswap_64(x) OSSwapInt64(x)
+#elif defined(__sun)
+#include <sys/byteorder.h>
+#define bswap_16(x) BSWAP_16(x)
+#define bswap_32(x) BSWAP_32(x)
+#define bswap_64(x) BSWAP_64(x)
#else
#include <byteswap.h>
#endif
</diff>
Brad