From: Satoshi Nakagawa Date: 2007-10-26T20:02:26+09:00 Subject: [ruby-dev:32160] WORDS_BIGENDIAN on Mac OS X 中川といいます。 ruby-core:12895 で Laurent が ruby 1.8 について > words-bigendian-from-arch.diff: This patch moves some code that was > only effective for NeXT systems, for both Mac OS X and NeXT. > WORDS_BIGENDIAN isn't trusted from configure, but instead we use > __BIG_ENDIAN__. This is to make sure you can build Ruby for both ppc > and i386 architectures (as a fat binary) on ppc, then use the binary > on i386 without getting endianness problems. と書いていますが、これは trunk にもあてはまります。 ruby-dev:31626 の strtod の件以来、気になっていたのですが、 Intel Mac で -arch i386 -arch ppc を指定して make してみると WORDS_BIGENDIAN は i386 と ppc のバイナリのどちらでも define されていないことを確認しました。 したがって、WORDS_BIGENDIAN を利用している部分は、 fat binary ではちゃんと動作していないはずだと思います。 Index: include/ruby/defines.h =================================================================== --- include/ruby/defines.h (revision 13787) +++ include/ruby/defines.h (working copy) @@ -106,6 +106,16 @@ #endif #endif +#if defined(__NeXT__) || defined(__APPLE__) +/* Do not trust WORDS_BIGENDIAN from configure since -arch compiler flag may + result in a different endian. Instead trust __BIG_ENDIAN__ and + __LITTLE_ENDIAN__ which are set correctly by -arch. */ +#undef WORDS_BIGENDIAN +#ifdef __BIG_ENDIAN__ +#define WORDS_BIGENDIAN +#endif +#endif + #ifdef __NeXT__ /* NextStep, OpenStep, Rhapsody */ #ifndef S_IRUSR @@ -159,13 +169,6 @@ #ifndef S_ISREG #define S_ISREG(mode) (((mode) & (0170000)) == (0100000)) #endif -/* Do not trust WORDS_BIGENDIAN from configure since -arch compiler flag may - result in a different endian. Instead trust __BIG_ENDIAN__ and - __LITTLE_ENDIAN__ which are set correctly by -arch. */ -#undef WORDS_BIGENDIAN -#ifdef __BIG_ENDIAN__ -#define WORDS_BIGENDIAN -#endif #ifndef __APPLE__ /* NextStep, OpenStep (but not Rhapsody) */ #ifndef GETPGRP_VOID -- Satoshi Nakagawa http://d.hatena.ne.jp/Psychs/