[POWERPC] Fix carry bug in 128-bit unsigned integer adding
authorLiu Yu <Yu.Liu@freescale.com>
Fri, 18 Jan 2008 03:21:39 +0000 (11:21 +0800)
committerKumar Gala <galak@kernel.crashing.org>
Thu, 24 Jan 2008 01:34:21 +0000 (19:34 -0600)
Synchronize it to the definition in include/math-emu/op-4.h for short term.

Signed-off-by: Liu Yu <Yu.Liu@freescale.com>
Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
arch/powerpc/math-emu/op-4.h

index fcdd6d064c5446bf89914baec032f1fe47715b8e..c9ae626070daf1d9d6e05e7c9882c5dc5757a092 100644 (file)
   (X##_f[3] = I3, X##_f[2] = I2, X##_f[1] = I1, X##_f[0] = I0)
 
 #ifndef __FP_FRAC_ADD_4
-#define __FP_FRAC_ADD_4(r3,r2,r1,r0,x3,x2,x1,x0,y3,y2,y1,y0)           \
-  (r0 = x0 + y0,                                                       \
-   r1 = x1 + y1 + (r0 < x0),                                           \
-   r2 = x2 + y2 + (r1 < x1),                                           \
-   r3 = x3 + y3 + (r2 < x2))
+#define __FP_FRAC_ADD_4(r3,r2,r1,r0,x3,x2,x1,x0,y3,y2,y1,y0)   \
+  do {                                                         \
+    int _c1, _c2, _c3;                                         \
+    r0 = x0 + y0;                                              \
+    _c1 = r0 < x0;                                             \
+    r1 = x1 + y1;                                              \
+    _c2 = r1 < x1;                                             \
+    r1 += _c1;                                                 \
+    _c2 |= r1 < _c1;                                           \
+    r2 = x2 + y2;                                              \
+    _c3 = r2 < x2;                                             \
+    r2 += _c2;                                                 \
+    _c3 |= r2 < _c2;                                           \
+    r3 = x3 + y3 + _c3;                                                \
+  } while (0)
 #endif
 
 #ifndef __FP_FRAC_SUB_4
-#define __FP_FRAC_SUB_4(r3,r2,r1,r0,x3,x2,x1,x0,y3,y2,y1,y0)           \
-  (r0 = x0 - y0,                                                        \
-   r1 = x1 - y1 - (r0 > x0),                                            \
-   r2 = x2 - y2 - (r1 > x1),                                            \
-   r3 = x3 - y3 - (r2 > x2))
+#define __FP_FRAC_SUB_4(r3,r2,r1,r0,x3,x2,x1,x0,y3,y2,y1,y0)   \
+  do {                                                         \
+    int _c1, _c2, _c3;                                         \
+    r0 = x0 - y0;                                              \
+    _c1 = r0 > x0;                                             \
+    r1 = x1 - y1;                                              \
+    _c2 = r1 > x1;                                             \
+    r1 -= _c1;                                                 \
+    _c2 |= r1 > _c1;                                           \
+    r2 = x2 - y2;                                              \
+    _c3 = r2 > x2;                                             \
+    r2 -= _c2;                                                 \
+    _c3 |= r2 > _c2;                                           \
+    r3 = x3 - y3 - _c3;                                                \
+  } while (0)
 #endif
 
 #ifndef __FP_FRAC_ADDI_4