From: Vincent Pit Date: Sat, 16 May 2009 08:19:40 +0000 (+0200) Subject: Test for little endianess more reliably X-Git-Tag: v0.06~16 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=32f2bff1c76f086abcd9e0557c3ffb1e2625667c;p=perl%2Fmodules%2FScalar-Vec-Util.git Test for little endianess more reliably --- diff --git a/Makefile.PL b/Makefile.PL index 6f4e066..ec065d3 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -37,8 +37,19 @@ if ($cc) { my @DEFINES; +sub is_little_endian { + my $order = $Config{byteorder}; + return 0 unless $order; + my $len = length $order; + if ($len > 8) { + $order = substr $order, 0, 8; + $len = 8; + } + return $order eq (join '', 1 .. $len); +} + my $unit = { bits => 8, size => 1 }; -if (unpack("h*", pack("s", 0x1234)) != 4321) { +if (not is_little_endian()) { print "Forcing unit size of 8 on non-little-endian systems.\n"; } else { print "Checking unit size in bits... ";