Changeset 10856


Ignore:
Timestamp:
2005-11-07T13:54:47+13:00 (18 years ago)
Author:
kjdon
Message:

added checks for endianness

Location:
trunk/gsdl
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/config.h.in

    r10855 r10856  
    1313/* Define if using alloca.c.  */
    1414#undef C_ALLOCA
     15
     16/* Define if big endian */
     17#undef WORDS_BIGENDIAN
    1518
    1619/* Define to empty if the keyword does not work.  */
  • trunk/gsdl/configure

    r10181 r10856  
    70327032 fi
    70337033
     7034
     7035# check for endianness
     7036echo "$as_me:$LINENO: checking whether byte ordering is bigendian" >&5
     7037echo $ECHO_N "checking whether byte ordering is bigendian... $ECHO_C" >&6
     7038if test "${ac_cv_c_bigendian+set}" = set; then
     7039  echo $ECHO_N "(cached) $ECHO_C" >&6
     7040else
     7041  # See if sys/param.h defines the BYTE_ORDER macro.
     7042cat >conftest.$ac_ext <<_ACEOF
     7043/* confdefs.h.  */
     7044_ACEOF
     7045cat confdefs.h >>conftest.$ac_ext
     7046cat >>conftest.$ac_ext <<_ACEOF
     7047/* end confdefs.h.  */
     7048#include <sys/types.h>
     7049#include <sys/param.h>
     7050
     7051int
     7052main ()
     7053{
     7054#if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN
     7055 bogus endian macros
     7056#endif
     7057
     7058  ;
     7059  return 0;
     7060}
     7061_ACEOF
     7062rm -f conftest.$ac_objext
     7063if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
     7064  (eval $ac_compile) 2>conftest.er1
     7065  ac_status=$?
     7066  grep -v '^ *+' conftest.er1 >conftest.err
     7067  rm -f conftest.er1
     7068  cat conftest.err >&5
     7069  echo "$as_me:$LINENO: \$? = $ac_status" >&5
     7070  (exit $ac_status); } &&
     7071     { ac_try='test -z "$ac_cxx_werror_flag"
     7072             || test ! -s conftest.err'
     7073  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
     7074  (eval $ac_try) 2>&5
     7075  ac_status=$?
     7076  echo "$as_me:$LINENO: \$? = $ac_status" >&5
     7077  (exit $ac_status); }; } &&
     7078     { ac_try='test -s conftest.$ac_objext'
     7079  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
     7080  (eval $ac_try) 2>&5
     7081  ac_status=$?
     7082  echo "$as_me:$LINENO: \$? = $ac_status" >&5
     7083  (exit $ac_status); }; }; then
     7084  # It does; now see whether it defined to BIG_ENDIAN or not.
     7085cat >conftest.$ac_ext <<_ACEOF
     7086/* confdefs.h.  */
     7087_ACEOF
     7088cat confdefs.h >>conftest.$ac_ext
     7089cat >>conftest.$ac_ext <<_ACEOF
     7090/* end confdefs.h.  */
     7091#include <sys/types.h>
     7092#include <sys/param.h>
     7093
     7094int
     7095main ()
     7096{
     7097#if BYTE_ORDER != BIG_ENDIAN
     7098 not big endian
     7099#endif
     7100
     7101  ;
     7102  return 0;
     7103}
     7104_ACEOF
     7105rm -f conftest.$ac_objext
     7106if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
     7107  (eval $ac_compile) 2>conftest.er1
     7108  ac_status=$?
     7109  grep -v '^ *+' conftest.er1 >conftest.err
     7110  rm -f conftest.er1
     7111  cat conftest.err >&5
     7112  echo "$as_me:$LINENO: \$? = $ac_status" >&5
     7113  (exit $ac_status); } &&
     7114     { ac_try='test -z "$ac_cxx_werror_flag"
     7115             || test ! -s conftest.err'
     7116  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
     7117  (eval $ac_try) 2>&5
     7118  ac_status=$?
     7119  echo "$as_me:$LINENO: \$? = $ac_status" >&5
     7120  (exit $ac_status); }; } &&
     7121     { ac_try='test -s conftest.$ac_objext'
     7122  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
     7123  (eval $ac_try) 2>&5
     7124  ac_status=$?
     7125  echo "$as_me:$LINENO: \$? = $ac_status" >&5
     7126  (exit $ac_status); }; }; then
     7127  ac_cv_c_bigendian=yes
     7128else
     7129  echo "$as_me: failed program was:" >&5
     7130sed 's/^/| /' conftest.$ac_ext >&5
     7131
     7132ac_cv_c_bigendian=no
     7133fi
     7134rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
     7135else
     7136  echo "$as_me: failed program was:" >&5
     7137sed 's/^/| /' conftest.$ac_ext >&5
     7138
     7139# It does not; compile a test program.
     7140if test "$cross_compiling" = yes; then
     7141  # try to guess the endianness by grepping values into an object file
     7142  ac_cv_c_bigendian=unknown
     7143  cat >conftest.$ac_ext <<_ACEOF
     7144/* confdefs.h.  */
     7145_ACEOF
     7146cat confdefs.h >>conftest.$ac_ext
     7147cat >>conftest.$ac_ext <<_ACEOF
     7148/* end confdefs.h.  */
     7149short ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 };
     7150short ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 };
     7151void _ascii () { char *s = (char *) ascii_mm; s = (char *) ascii_ii; }
     7152short ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 };
     7153short ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 };
     7154void _ebcdic () { char *s = (char *) ebcdic_mm; s = (char *) ebcdic_ii; }
     7155int
     7156main ()
     7157{
     7158 _ascii (); _ebcdic ();
     7159  ;
     7160  return 0;
     7161}
     7162_ACEOF
     7163rm -f conftest.$ac_objext
     7164if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
     7165  (eval $ac_compile) 2>conftest.er1
     7166  ac_status=$?
     7167  grep -v '^ *+' conftest.er1 >conftest.err
     7168  rm -f conftest.er1
     7169  cat conftest.err >&5
     7170  echo "$as_me:$LINENO: \$? = $ac_status" >&5
     7171  (exit $ac_status); } &&
     7172     { ac_try='test -z "$ac_cxx_werror_flag"
     7173             || test ! -s conftest.err'
     7174  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
     7175  (eval $ac_try) 2>&5
     7176  ac_status=$?
     7177  echo "$as_me:$LINENO: \$? = $ac_status" >&5
     7178  (exit $ac_status); }; } &&
     7179     { ac_try='test -s conftest.$ac_objext'
     7180  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
     7181  (eval $ac_try) 2>&5
     7182  ac_status=$?
     7183  echo "$as_me:$LINENO: \$? = $ac_status" >&5
     7184  (exit $ac_status); }; }; then
     7185  if grep BIGenDianSyS conftest.$ac_objext >/dev/null ; then
     7186  ac_cv_c_bigendian=yes
     7187fi
     7188if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then
     7189  if test "$ac_cv_c_bigendian" = unknown; then
     7190    ac_cv_c_bigendian=no
     7191  else
     7192    # finding both strings is unlikely to happen, but who knows?
     7193    ac_cv_c_bigendian=unknown
     7194  fi
     7195fi
     7196else
     7197  echo "$as_me: failed program was:" >&5
     7198sed 's/^/| /' conftest.$ac_ext >&5
     7199
     7200fi
     7201rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
     7202else
     7203  cat >conftest.$ac_ext <<_ACEOF
     7204/* confdefs.h.  */
     7205_ACEOF
     7206cat confdefs.h >>conftest.$ac_ext
     7207cat >>conftest.$ac_ext <<_ACEOF
     7208/* end confdefs.h.  */
     7209int
     7210main ()
     7211{
     7212  /* Are we little or big endian?  From Harbison&Steele.  */
     7213  union
     7214  {
     7215    long l;
     7216    char c[sizeof (long)];
     7217  } u;
     7218  u.l = 1;
     7219  exit (u.c[sizeof (long) - 1] == 1);
     7220}
     7221_ACEOF
     7222rm -f conftest$ac_exeext
     7223if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
     7224  (eval $ac_link) 2>&5
     7225  ac_status=$?
     7226  echo "$as_me:$LINENO: \$? = $ac_status" >&5
     7227  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
     7228  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
     7229  (eval $ac_try) 2>&5
     7230  ac_status=$?
     7231  echo "$as_me:$LINENO: \$? = $ac_status" >&5
     7232  (exit $ac_status); }; }; then
     7233  ac_cv_c_bigendian=no
     7234else
     7235  echo "$as_me: program exited with status $ac_status" >&5
     7236echo "$as_me: failed program was:" >&5
     7237sed 's/^/| /' conftest.$ac_ext >&5
     7238
     7239( exit $ac_status )
     7240ac_cv_c_bigendian=yes
     7241fi
     7242rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
     7243fi
     7244fi
     7245rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
     7246fi
     7247echo "$as_me:$LINENO: result: $ac_cv_c_bigendian" >&5
     7248echo "${ECHO_T}$ac_cv_c_bigendian" >&6
     7249case $ac_cv_c_bigendian in
     7250  yes)
     7251
     7252cat >>confdefs.h <<\_ACEOF
     7253#define WORDS_BIGENDIAN 1
     7254_ACEOF
     7255 ;;
     7256  no)
     7257     ;;
     7258  *)
     7259    { { echo "$as_me:$LINENO: error: unknown endianness
     7260presetting ac_cv_c_bigendian=no (or yes) will help" >&5
     7261echo "$as_me: error: unknown endianness
     7262presetting ac_cv_c_bigendian=no (or yes) will help" >&2;}
     7263   { (exit 1); exit 1; }; } ;;
     7264esac
    70347265
    70357266# ---------------------------------------------------------------------------
  • trunk/gsdl/configure.in

    r10181 r10856  
    366366AC_SUBST(gsdlos)
    367367
     368# check for endianness
     369AC_C_BIGENDIAN
    368370# ---------------------------------------------------------------------------
    369371if test "$ac_cv_func_alloca" = 'no'; then
Note: See TracChangeset for help on using the changeset viewer.