* defs.h (SWAP_TARGET_AND_HOST): check endianess at runtime not
authorKung Hsu <kung@cygnus>
Wed, 1 Mar 1995 02:13:06 +0000 (02:13 +0000)
committerKung Hsu <kung@cygnus>
Wed, 1 Mar 1995 02:13:06 +0000 (02:13 +0000)
        compile time.

gdb/ChangeLog
gdb/defs.h

index 33bcbe3aa08bb92cc806f5d9a0b69148fbc10305..b6096eefda1f5e4e879a9fffee01c6c016a6c594 100644 (file)
@@ -1,5 +1,8 @@
 Tue Feb 28 14:38:39 1995  Kung Hsu  <kung@mexican.cygnus.com>
 
+       * defs.h (SWAP_TARGET_AND_HOST): check endianess at runtime not
+       compile time.
+
        * arc-tdep.c (_initialize_arc_tdep): set tm_print_insn according to 
        processor.
        * remote-arc.c (arc_wait): when a processor stops, stop other two
index 5f09ba7c841eaa8dbdc1e5a7245b542676c4d888..884d5ad248fc46037f878ac3cad003f006df8f1a 100644 (file)
@@ -741,22 +741,23 @@ extern void set_endian_from_file PARAMS ((bfd *));
 #endif /* BITS_BIG_ENDIAN not defined.  */
 
 /* Swap LEN bytes at BUFFER between target and host byte-order.  */
-#if TARGET_BYTE_ORDER == HOST_BYTE_ORDER
-#define SWAP_TARGET_AND_HOST(buffer,len)
-#else /* Target and host byte order differ.  */
 #define SWAP_TARGET_AND_HOST(buffer,len) \
-  {                                                                      \
-    char __tmp_;                                                        \
-    char *p = (char *)(buffer);                                          \
-    char *q = ((char *)(buffer)) + len - 1;                              \
-    for (; p < q; p++, q--)                                              \
-      {                                                                  \
-        __tmp_ = *q;                                                     \
-        *q = *p;                                                         \
-        *p = __tmp_;                                                     \
-      }                                                                  \
-  }
-#endif /* Target and host byte order differ.  */
+  do                                                                    \
+    {                                                                   \
+      if (TARGET_BYTE_ORDER != HOST_BYTE_ORDER)                         \
+        {                                                               \
+          char tmp;                                                     \
+          char *p = (char *)(buffer);                                   \
+          char *q = ((char *)(buffer)) + len - 1;                       \
+          for (; p < q; p++, q--)                                       \
+            {                                                           \
+              tmp = *q;                                                 \
+              *q = *p;                                                  \
+              *p = tmp;                                                 \
+            }                                                           \
+        }                                                               \
+    }                                                                   \
+  while (0)
 
 /* In findvar.c.  */