]> granicus.if.org Git - strace/commitdiff
Check for endianness of long long
authorJohn Hughes <john@Calva.COM>
Wed, 28 Mar 2001 08:05:27 +0000 (08:05 +0000)
committerJohn Hughes <john@Calva.COM>
Wed, 28 Mar 2001 08:05:27 +0000 (08:05 +0000)
ChangeLog
acconfig.h
aclocal.m4
configure.in
defs.h

index 66af8ea8164e2c91c326df5e8a1799a84acfac8b..7b029d6ae4b67845ca2b568365b10e15f737a4c2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2001-03-27  John Hughes <john@Calva.COM>
+
+  * 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 <john@Calva.COM>
 
   * net.c: Make compilable by SCO UDK compiler (doesn't like empty
index eb45d57364d4dba0a2a603f80d53e5dcc600b77b..b56c34e14eee7e49e9a000015d1098d58e2b5ad8 100644 (file)
 
 /* 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
index 27a6cc6eb94cf7116f50b71e3572c0a0100944ca..018ca91796b1b5181796af8be97de4b094240f13 100644 (file)
@@ -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
+])
+
index 3847550c0853a92f72e496b8a8e8afe372315f41..71b26ddcda33d75c21fd1bc2c9c21a432c33d776 100644 (file)
@@ -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 29c450e0dbedeac52d4620c1afe2c016cf04b023..41be06bf3b8a8e4b7feb57faf88fbcf516bfd8a3 100644 (file)
--- 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