From: John Hughes Date: Wed, 28 Mar 2001 08:05:27 +0000 (+0000) Subject: Check for endianness of long long X-Git-Tag: v4.5.18~1068 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b8a85a49ae738655cec81bd9e7bcb0bd6f5c9442;p=strace Check for endianness of long long --- diff --git a/ChangeLog b/ChangeLog index 66af8ea8..7b029d6a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2001-03-27 John Hughes + + * aclocal.m4: add check for endianness of long long. + * acconfig.h: add #define for LITTLE_ENDIAN_LONG_LONG. + * configure.in: check for endianness of long long. + * defs.h: change LONG_LONG macro to wirk with either endianness of + long long. + 2001-03-27 John Hughes * net.c: Make compilable by SCO UDK compiler (doesn't like empty diff --git a/acconfig.h b/acconfig.h index eb45d573..b56c34e1 100644 --- a/acconfig.h +++ b/acconfig.h @@ -107,3 +107,6 @@ /* Define if have st_gen in struct stat */ #undef HAVE_ST_GEN + +/* Define if have little endiang long long */ +#undef HAVE_LITTLE_ENDIAN_LONG_LONG diff --git a/aclocal.m4 b/aclocal.m4 index 27a6cc6e..018ca917 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -481,3 +481,31 @@ then fi ]) +dnl ### A macro to determine endianness of long long +AC_DEFUN(AC_LITTLE_ENDIAN_LONG_LONG, +[AC_MSG_CHECKING(for little endian long long) +AC_CACHE_VAL(ac_cv_have_little_endian_long_long, +[AC_TRY_RUN([ +int main () { + union { + long long ll; + long l [2]; + } u; + u.ll = 0x12345678; + if (u.l[0] == 0x12345678) + return 0; + return 1; +} +], +ac_cv_have_little_endian_long_long=yes, +ac_cv_have_little_endian_long_long=no, +[# Should try to guess here +ac_cv_have_little_endian_long_long=no +])]) +AC_MSG_RESULT($ac_cv_have_little_endian_long_long) +if test "$ac_cv_have_little_endian_long_long" = yes +then + AC_DEFINE(HAVE_LITTLE_ENDIAN_LONG_LONG) +fi +]) + diff --git a/configure.in b/configure.in index 3847550c..71b26ddc 100644 --- a/configure.in +++ b/configure.in @@ -151,6 +151,7 @@ AC_SIG_ATOMIC_T AC_STAT64 AC_SIN6_SCOPE_ID AC_LONG_LONG +AC_LITTLE_ENDIAN_LONG_LONG AC_OFF_T_IS_LONG_LONG AC_RLIM_T_IS_LONG_LONG AC_ST_FLAGS diff --git a/defs.h b/defs.h index 29c450e0..41be06bf 100644 --- a/defs.h +++ b/defs.h @@ -522,16 +522,7 @@ do { \ * _h refers to the higher numbered u_arg */ -#if 1 -/* This should work, assuming we can do non-aligned 64 bit fetches. - * if not we'll have to figure out how which of the other versions to use. - */ - -#define LONG_LONG(_l,_h) (*(long long *) &(_l)) - -#else - -#if _LITTLE_ENDIAN +#if HAVE_LITTLE_ENDIAN_LONG_LONG #define LONG_LONG(_l,_h) \ ((long long)((unsigned long long)(_l) | ((unsigned long long)(_h)<<32))) #else @@ -539,4 +530,3 @@ do { \ ((long long)((unsigned long long)(_h) | ((unsigned long long)(_l)<<32))) #endif #endif -#endif