PowerPC floating point little-endian [15 of 15]
authorAlan Modra <amodra@gmail.com>
Sat, 17 Aug 2013 09:03:45 +0000 (18:33 +0930)
committerAlan Modra <amodra@gmail.com>
Fri, 4 Oct 2013 01:07:27 +0000 (10:37 +0930)
http://sourceware.org/ml/libc-alpha/2013-07/msg00206.html

The union loses when little-endian.

* sysdeps/powerpc/powerpc32/power4/hp-timing.h (HP_TIMING_NOW):
Don't use a union to pack hi/low value.

ChangeLog
sysdeps/powerpc/powerpc32/power4/hp-timing.h

index f84a9e4..89f5105 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2013-10-04  Alan Modra  <amodra@gmail.com>
+
+       * sysdeps/powerpc/powerpc32/power4/hp-timing.h (HP_TIMING_NOW):
+       Don't use a union to pack hi/low value.
+
 2013-10-04  Anton Blanchard <anton@au1.ibm.com>
 
        * sysdeps/powerpc/powerpc64/fpu/s_ceilf.S: Correct float constants
index 7d6c96e..4e42374 100644 (file)
@@ -87,18 +87,15 @@ typedef unsigned long long int hp_timing_t;
 
 #define HP_TIMING_NOW(Var)                                             \
   do {                                                                 \
-        union { long long ll; long ii[2]; } _var;                      \
-       long tmp;                                                       \
-        __asm__ __volatile__ (                                         \
-               "1:     mfspr   %0,269;"                                \
-               "       mfspr   %1,268;"                                \
-               "       mfspr   %2,269;"                                \
-               "       cmpw    %0,%2;"                                 \
-               "       bne     1b;"                                    \
-               : "=r" (_var.ii[0]), "=r" (_var.ii[1]) , "=r" (tmp)     \
-               : : "cr0"                                               \
-               );                                                      \
-       Var = _var.ll;                                                  \
+    unsigned int hi, lo, tmp;                                          \
+    __asm__ __volatile__ ("1:  mfspr   %0,269;"                        \
+                         "     mfspr   %1,268;"                        \
+                         "     mfspr   %2,269;"                        \
+                         "     cmpw    %0,%2;"                         \
+                         "     bne     1b;"                            \
+                         : "=&r" (hi), "=&r" (lo), "=&r" (tmp)         \
+                         : : "cr0");                                   \
+    Var = ((hp_timing_t) hi << 32) | lo;                               \
   } while (0)