PPC detected as little endian (!)

Matías Giovannini <[email protected]> Wed, 26 Sep 2012 19:25:55 -0300
Newsgroups gmane.comp.lang.ocaml.lib.net.devel
Message-ID <CALzEXo9RE5qZuwQ9+L_x=8zx6LEKmsL8GO34YSokWHfqHnpdbw@mail.gmail.com>
--===============2592507436307352063==
Content-Type: multipart/alternative; boundary=20cf30363f736685c504caa24e66

--20cf30363f736685c504caa24e66
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Hello,

after seeing ocamlnet 3.6 fail spectacularly on a Power Mac, I tried
recompiling and watching closely the configuration options. Lo and behold,
configure proudly proclaims:

Checking endianess... little

which is of course completely wrong. The problem is that pointer aliasing
via unions is undefined behavior in C (barring packing pragmas and other
compiler wizardry), and GCC/LLVM do whatever they want with that code. I've
found that I can distinguish endianness reliably with the following check:

value check(value d) {
  int i =3D 1;
  char *s =3D (char*) &i;
  return (s[0] =3D=3D 0 ? Val_true : Val_false);
}

Regards,
Mat=C3=ADas.

--20cf30363f736685c504caa24e66
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Hello,<div><br></div><div>after seeing ocamlnet 3.6 fail spectacularly on a=
 Power Mac, I tried recompiling and watching closely the configuration opti=
ons. Lo and behold, configure proudly proclaims:</div><div><br></div><div>
<div>Checking endianess... little</div></div><div><br></div><div>which is o=
f course completely wrong. The problem is that pointer aliasing via unions =
is undefined behavior in C (barring packing pragmas and other compiler wiza=
rdry), and GCC/LLVM do whatever they want with that code. I&#39;ve found th=
at I can distinguish endianness reliably with the following check:</div>
<div><br></div><div><div>value check(value d) {</div><div>=C2=A0 int i =3D =
1;</div><div>=C2=A0 char *s =3D (char*) &amp;i;</div><div>=C2=A0 return (s[=
0] =3D=3D 0 ? Val_true : Val_false);</div><div>}</div></div><div><br></div>=
<div>Regards,</div>
<div>Mat=C3=ADas.</div>

--20cf30363f736685c504caa24e66--


--===============2592507436307352063==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

------------------------------------------------------------------------------
How fast is your code?
3 out of 4 devs don\\\'t know how their code performs in production.
Find out how slow your code is with AppDynamics Lite.
http://ad.doubleclick.net/clk;262219672;13503038;z?
http://info.appdynamics.com/FreeJavaPerformanceDownload.html
--===============2592507436307352063==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Ocamlnet-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ocamlnet-devel

--===============2592507436307352063==--