Skip to contentSkip to conversation

math-emu: delete PowerPC old math-emu headers

PATCH In review Liu Yu 2 participants 6 messages Mar 5, 2008 – Mar 6, 2008 PowerPC

lore
Share & tools
lore

Liu Yu

author
#0 lore raw

PATCH 1/1 math-emu: delete PowerPC old math-emu headers

Use common headers as a replacement.
The Common headers are located in "include/math-emu/", they are used by multiple platforms such as s390, sparc, alpha.

As the common headers have more developers,
they are more popular and more stable.

In fact, PowerPC old math-emu headers cannot handle float point exceptions exactly while the common headers can.

---
 arch/powerpc/math-emu/double.h                     |  129 ----
 arch/powerpc/math-emu/op-1.h                       |  245 -------
 arch/powerpc/math-emu/op-2.h                       |  434 ------------
 arch/powerpc/math-emu/op-4.h                       |  317 ---------
 arch/powerpc/math-emu/op-common.h                  |  688 --------------------
 arch/powerpc/math-emu/single.h                     |   66 --
 arch/powerpc/math-emu/soft-fp.h                    |  104 ---
 arch/powerpc/math-emu/types.c                      |   51 --
 .../math-emu => include/asm-powerpc}/sfp-machine.h |    0 
 9 files changed, 0 insertions(+), 2034 deletions(-)
 delete mode 100644 arch/powerpc/math-emu/double.h
 delete mode 100644 arch/powerpc/math-emu/op-1.h
 delete mode 100644 arch/powerpc/math-emu/op-2.h
 delete mode 100644 arch/powerpc/math-emu/op-4.h
 delete mode 100644 arch/powerpc/math-emu/op-common.h
 delete mode 100644 arch/powerpc/math-emu/single.h
 delete mode 100644 arch/powerpc/math-emu/soft-fp.h
 delete mode 100644 arch/powerpc/math-emu/types.c
 rename {arch/powerpc/math-emu => include/asm-powerpc}/sfp-machine.h (100%)
arch/powerpc/math-emu/double.h deleted +0 -129
deleted file mode 100644
index ffba8b6..0000000
@@ -1,129 +0,0 @@
-/*
- * Definitions for IEEE Double Precision
- */
-
-#if _FP_W_TYPE_SIZE < 32
-#error "Here's a nickel kid.  Go buy yourself a real computer."
-#endif
-
-#if _FP_W_TYPE_SIZE < 64
-#define _FP_FRACTBITS_D		(2 * _FP_W_TYPE_SIZE)
-#else
-#define _FP_FRACTBITS_D		_FP_W_TYPE_SIZE
-#endif
-
-#define _FP_FRACBITS_D		53
-#define _FP_FRACXBITS_D		(_FP_FRACTBITS_D - _FP_FRACBITS_D)
-#define _FP_WFRACBITS_D		(_FP_WORKBITS + _FP_FRACBITS_D)
-#define _FP_WFRACXBITS_D	(_FP_FRACTBITS_D - _FP_WFRACBITS_D)
-#define _FP_EXPBITS_D		11
-#define _FP_EXPBIAS_D		1023
-#define _FP_EXPMAX_D		2047
-
-#define _FP_QNANBIT_D		\
-	((_FP_W_TYPE)1 << ((_FP_FRACBITS_D-2) % _FP_W_TYPE_SIZE))
-#define _FP_IMPLBIT_D		\
-	((_FP_W_TYPE)1 << ((_FP_FRACBITS_D-1) % _FP_W_TYPE_SIZE))
-#define _FP_OVERFLOW_D		\
-	((_FP_W_TYPE)1 << (_FP_WFRACBITS_D % _FP_W_TYPE_SIZE))
-
-#if _FP_W_TYPE_SIZE < 64
-
-union _FP_UNION_D
-{
-  double flt;
-  struct {
-#if __BYTE_ORDER == __BIG_ENDIAN
-    unsigned sign  : 1;
-    unsigned exp   : _FP_EXPBITS_D;
-    unsigned frac1 : _FP_FRACBITS_D - (_FP_IMPLBIT_D != 0) - _FP_W_TYPE_SIZE;
-    unsigned frac0 : _FP_W_TYPE_SIZE;
-#else
-    unsigned frac0 : _FP_W_TYPE_SIZE;
-    unsigned frac1 : _FP_FRACBITS_D - (_FP_IMPLBIT_D != 0) - _FP_W_TYPE_SIZE;
-    unsigned exp   : _FP_EXPBITS_D;
-    unsigned sign  : 1;
-#endif
-  } bits __attribute__((packed));
-};
-
-#define FP_DECL_D(X)		_FP_DECL(2,X)
-#define FP_UNPACK_RAW_D(X,val)	_FP_UNPACK_RAW_2(D,X,val)
-#define FP_PACK_RAW_D(val,X)	_FP_PACK_RAW_2(D,val,X)
-
-#define FP_UNPACK_D(X,val)		\
-  do {					\
-    _FP_UNPACK_RAW_2(D,X,val);		\
-    _FP_UNPACK_CANONICAL(D,2,X);	\
-  } while (0)
-
-#define FP_PACK_D(val,X)		\
-  do {					\
-    _FP_PACK_CANONICAL(D,2,X);		\
-    _FP_PACK_RAW_2(D,val,X);		\
-  } while (0)
-
-#define FP_NEG_D(R,X)		_FP_NEG(D,2,R,X)
-#define FP_ADD_D(R,X,Y)		_FP_ADD(D,2,R,X,Y)
-#define FP_SUB_D(R,X,Y)		_FP_SUB(D,2,R,X,Y)
-#define FP_MUL_D(R,X,Y)		_FP_MUL(D,2,R,X,Y)
-#define FP_DIV_D(R,X,Y)		_FP_DIV(D,2,R,X,Y)
-#define FP_SQRT_D(R,X)		_FP_SQRT(D,2,R,X)
-
-#define FP_CMP_D(r,X,Y,un)	_FP_CMP(D,2,r,X,Y,un)
-#define FP_CMP_EQ_D(r,X,Y)	_FP_CMP_EQ(D,2,r,X,Y)
-
-#define FP_TO_INT_D(r,X,rsz,rsg)  _FP_TO_INT(D,2,r,X,rsz,rsg)
-#define FP_FROM_INT_D(X,r,rs,rt)  _FP_FROM_INT(D,2,X,r,rs,rt)
-
-#else
-
-union _FP_UNION_D
-{
-  double flt;
-  struct {
-#if __BYTE_ORDER == __BIG_ENDIAN
-    unsigned sign : 1;
-    unsigned exp  : _FP_EXPBITS_D;
-    unsigned long frac : _FP_FRACBITS_D - (_FP_IMPLBIT_D != 0);
-#else
-    unsigned long frac : _FP_FRACBITS_D - (_FP_IMPLBIT_D != 0);
-    unsigned exp  : _FP_EXPBITS_D;
-    unsigned sign : 1;
-#endif
-  } bits __attribute__((packed));
-};
-
-#define FP_DECL_D(X)		_FP_DECL(1,X)
-#define FP_UNPACK_RAW_D(X,val)	_FP_UNPACK_RAW_1(D,X,val)
-#define FP_PACK_RAW_D(val,X)	_FP_PACK_RAW_1(D,val,X)
-
-#define FP_UNPACK_D(X,val)		\
-  do {					\
-    _FP_UNPACK_RAW_1(D,X,val);		\
-    _FP_UNPACK_CANONICAL(D,1,X);	\
-  } while (0)
-
-#define FP_PACK_D(val,X)		\
-  do {					\
-    _FP_PACK_CANONICAL(D,1,X);		\
-    _FP_PACK_RAW_1(D,val,X);		\
-  } while (0)
-
-#define FP_NEG_D(R,X)		_FP_NEG(D,1,R,X)
-#define FP_ADD_D(R,X,Y)		_FP_ADD(D,1,R,X,Y)
-#define FP_SUB_D(R,X,Y)		_FP_SUB(D,1,R,X,Y)
-#define FP_MUL_D(R,X,Y)		_FP_MUL(D,1,R,X,Y)
-#define FP_DIV_D(R,X,Y)		_FP_DIV(D,1,R,X,Y)
-#define FP_SQRT_D(R,X)		_FP_SQRT(D,1,R,X)
-
-/* The implementation of _FP_MUL_D and _FP_DIV_D should be chosen by
-   the target machine.  */
-
-#define FP_CMP_D(r,X,Y,un)	_FP_CMP(D,1,r,X,Y,un)
-#define FP_CMP_EQ_D(r,X,Y)	_FP_CMP_EQ(D,1,r,X,Y)
-
-#define FP_TO_INT_D(r,X,rsz,rsg)  _FP_TO_INT(D,1,r,X,rsz,rsg)
-#define FP_FROM_INT_D(X,r,rs,rt)  _FP_FROM_INT(D,1,X,r,rs,rt)
-
-#endif /* W_TYPE_SIZE < 64 */
arch/powerpc/math-emu/op-1.h deleted +0 -245

245 lines not on this page · raw message

arch/powerpc/math-emu/op-2.h deleted +0 -434

434 lines not on this page · raw message

arch/powerpc/math-emu/op-4.h deleted +0 -317

317 lines not on this page · raw message

arch/powerpc/math-emu/op-common.h deleted +0 -688

688 lines not on this page · raw message

arch/powerpc/math-emu/single.h deleted +0 -66

66 lines not on this page · raw message

arch/powerpc/math-emu/soft-fp.h deleted +0 -104

104 lines not on this page · raw message

arch/powerpc/math-emu/types.c deleted +0 -51

51 lines not on this page · raw message

include/asm-powerpc/sfp-machine.h renamed from arch/powerpc/math-emu/sfp-machine.h +0 -0
similarity index 100%
rename from arch/powerpc/math-emu/sfp-machine.h
rename to include/asm-powerpc/sfp-machine.h
Signature · 1 line
1.5.2
author
#1 lore raw

PATCH 1/1 math-emu: modify the sfp-machine.h to fit the new interface of common math-emu headers

---
 include/asm-powerpc/sfp-machine.h |  217 +++++++++++++------------------------
 1 files changed, 75 insertions(+), 142 deletions(-)
include/asm-powerpc/sfp-machine.h +75 -142
index 4b17d83..5dac9cd 100644
@@ -45,159 +45,46 @@
  * gcc's longlong.h is useful.
  */
 
-/* We need to know how to multiply and divide. If the host word size
- * is >= 2*fracbits you can use FP_MUL_MEAT_n_imm(t,R,X,Y) which
- * codes the multiply with whatever gcc does to 'a * b'.
- * _FP_MUL_MEAT_n_wide(t,R,X,Y,f) is used when you have an asm
- * function that can multiply two 1W values and get a 2W result.
- * Otherwise you're stuck with _FP_MUL_MEAT_n_hard(t,R,X,Y) which
- * does bitshifting to avoid overflow.
- * For division there is FP_DIV_MEAT_n_imm(t,R,X,Y,f) for word size
- * >= 2*fracbits, where f is either _FP_DIV_HELP_imm or
- * _FP_DIV_HELP_ldiv (see op-1.h).
- * _FP_DIV_MEAT_udiv() is if you have asm to do 2W/1W => (1W, 1W).
- * [GCC and glibc have longlong.h which has the asm macro udiv_qrnnd
- * to do this.]
- * In general, 'n' is the number of words required to hold the type,
- * and 't' is either S, D or Q for single/double/quad.
- *           -- PMM
- */
-/* Example: SPARC64:
- * #define _FP_MUL_MEAT_S(R,X,Y)	_FP_MUL_MEAT_1_imm(S,R,X,Y)
- * #define _FP_MUL_MEAT_D(R,X,Y)	_FP_MUL_MEAT_1_wide(D,R,X,Y,umul_ppmm)
- * #define _FP_MUL_MEAT_Q(R,X,Y)	_FP_MUL_MEAT_2_wide(Q,R,X,Y,umul_ppmm)
- *
- * #define _FP_DIV_MEAT_S(R,X,Y)	_FP_DIV_MEAT_1_imm(S,R,X,Y,_FP_DIV_HELP_imm)
- * #define _FP_DIV_MEAT_D(R,X,Y)	_FP_DIV_MEAT_1_udiv(D,R,X,Y)
- * #define _FP_DIV_MEAT_Q(R,X,Y)	_FP_DIV_MEAT_2_udiv_64(Q,R,X,Y)
- *
- * Example: i386:
- * #define _FP_MUL_MEAT_S(R,X,Y)   _FP_MUL_MEAT_1_wide(S,R,X,Y,_i386_mul_32_64)
- * #define _FP_MUL_MEAT_D(R,X,Y)   _FP_MUL_MEAT_2_wide(D,R,X,Y,_i386_mul_32_64)
- *
- * #define _FP_DIV_MEAT_S(R,X,Y)   _FP_DIV_MEAT_1_udiv(S,R,X,Y,_i386_div_64_32)
- * #define _FP_DIV_MEAT_D(R,X,Y)   _FP_DIV_MEAT_2_udiv_64(D,R,X,Y)
- */
-
-#define _FP_MUL_MEAT_S(R,X,Y)   _FP_MUL_MEAT_1_wide(S,R,X,Y,umul_ppmm)
-#define _FP_MUL_MEAT_D(R,X,Y)   _FP_MUL_MEAT_2_wide(D,R,X,Y,umul_ppmm)
+#define _FP_MUL_MEAT_S(R,X,Y)					\
+  _FP_MUL_MEAT_1_wide(_FP_WFRACBITS_S,R,X,Y,umul_ppmm)
+#define _FP_MUL_MEAT_D(R,X,Y)					\
+  _FP_MUL_MEAT_2_wide(_FP_WFRACBITS_D,R,X,Y,umul_ppmm)
 
 #define _FP_DIV_MEAT_S(R,X,Y)   _FP_DIV_MEAT_1_udiv(S,R,X,Y)
-#define _FP_DIV_MEAT_D(R,X,Y)   _FP_DIV_MEAT_2_udiv_64(D,R,X,Y)
+#define _FP_DIV_MEAT_D(R,X,Y)   _FP_DIV_MEAT_2_udiv(D,R,X,Y)
 
 /* These macros define what NaN looks like. They're supposed to expand to
  * a comma-separated set of 32bit unsigned ints that encode NaN.
  */
-#define _FP_NANFRAC_S		_FP_QNANBIT_S
-#define _FP_NANFRAC_D		_FP_QNANBIT_D, 0
-#define _FP_NANFRAC_Q           _FP_QNANBIT_Q, 0, 0, 0
+#define _FP_NANFRAC_S		((_FP_QNANBIT_S << 1) - 1)
+#define _FP_NANFRAC_D		((_FP_QNANBIT_D << 1) - 1), -1
+#define _FP_NANFRAC_Q		((_FP_QNANBIT_Q << 1) - 1), -1, -1, -1
+#define _FP_NANSIGN_S		0
+#define _FP_NANSIGN_D		0
+#define _FP_NANSIGN_Q		0
 
 #define _FP_KEEPNANFRACP 1
 
-/* This macro appears to be called when both X and Y are NaNs, and
- * has to choose one and copy it to R. i386 goes for the larger of the
- * two, sparc64 just picks Y. I don't understand this at all so I'll
- * go with sparc64 because it's shorter :->   -- PMM
+/*
+ * If one NaN is signaling and the other is not,
+ * we choose that one, otherwise we choose X.
  */
-#define _FP_CHOOSENAN(fs, wc, R, X, Y)			\
-  do {							\
-    R##_s = Y##_s;					\
-    _FP_FRAC_COPY_##wc(R,Y);				\
-    R##_c = FP_CLS_NAN;					\
-  } while (0)
-
-
-extern void fp_unpack_d(long *, unsigned long *, unsigned long *,
-			long *, long *, void *);
-extern int  fp_pack_d(void *, long, unsigned long, unsigned long, long, long);
-extern int  fp_pack_ds(void *, long, unsigned long, unsigned long, long, long);
-
-#define __FP_UNPACK_RAW_1(fs, X, val)			\
-  do {							\
-    union _FP_UNION_##fs *_flo =			\
-    	(union _FP_UNION_##fs *)val;			\
-							\
-    X##_f = _flo->bits.frac;				\
-    X##_e = _flo->bits.exp;				\
-    X##_s = _flo->bits.sign;				\
-  } while (0)
-
-#define __FP_UNPACK_RAW_2(fs, X, val)			\
-  do {							\
-    union _FP_UNION_##fs *_flo =			\
-    	(union _FP_UNION_##fs *)val;			\
-							\
-    X##_f0 = _flo->bits.frac0;				\
-    X##_f1 = _flo->bits.frac1;				\
-    X##_e  = _flo->bits.exp;				\
-    X##_s  = _flo->bits.sign;				\
+#define _FP_CHOOSENAN(fs, wc, R, X, Y, OP)                      \
+  do {                                                          \
+    if ((_FP_FRAC_HIGH_RAW_##fs(X) & _FP_QNANBIT_##fs)          \
+        && !(_FP_FRAC_HIGH_RAW_##fs(Y) & _FP_QNANBIT_##fs))     \
+      {                                                         \
+        R##_s = Y##_s;                                          \
+        _FP_FRAC_COPY_##wc(R,Y);                                \
+      }                                                         \
+    else                                                        \
+      {                                                         \
+        R##_s = X##_s;                                          \
+        _FP_FRAC_COPY_##wc(R,X);                                \
+      }                                                         \
+    R##_c = FP_CLS_NAN;                                         \
   } while (0)
 
-#define __FP_UNPACK_S(X,val)		\
-  do {					\
-    __FP_UNPACK_RAW_1(S,X,val);		\
-    _FP_UNPACK_CANONICAL(S,1,X);	\
-  } while (0)
-
-#define __FP_UNPACK_D(X,val)		\
-	fp_unpack_d(&X##_s, &X##_f1, &X##_f0, &X##_e, &X##_c, val)
-
-#define __FP_PACK_RAW_1(fs, val, X)			\
-  do {							\
-    union _FP_UNION_##fs *_flo =			\
-    	(union _FP_UNION_##fs *)val;			\
-							\
-    _flo->bits.frac = X##_f;				\
-    _flo->bits.exp  = X##_e;				\
-    _flo->bits.sign = X##_s;				\
-  } while (0)
-
-#define __FP_PACK_RAW_2(fs, val, X)			\
-  do {							\
-    union _FP_UNION_##fs *_flo =			\
-    	(union _FP_UNION_##fs *)val;			\
-							\
-    _flo->bits.frac0 = X##_f0;				\
-    _flo->bits.frac1 = X##_f1;				\
-    _flo->bits.exp   = X##_e;				\
-    _flo->bits.sign  = X##_s;				\
-  } while (0)
-
-#include <linux/kernel.h>
-#include <linux/sched.h>
-
-#define __FPU_FPSCR	(current->thread.fpscr.val)
-
-/* We only actually write to the destination register
- * if exceptions signalled (if any) will not trap.
- */
-#define __FPU_ENABLED_EXC \
-({						\
-	(__FPU_FPSCR >> 3) & 0x1f;	\
-})
-
-#define __FPU_TRAP_P(bits) \
-	((__FPU_ENABLED_EXC & (bits)) != 0)
-
-#define __FP_PACK_S(val,X)			\
-({  int __exc = _FP_PACK_CANONICAL(S,1,X);	\
-    if(!__exc || !__FPU_TRAP_P(__exc))		\
-        __FP_PACK_RAW_1(S,val,X);		\
-    __exc;					\
-})
-
-#define __FP_PACK_D(val,X)			\
-	fp_pack_d(val, X##_s, X##_f1, X##_f0, X##_e, X##_c)
-
-#define __FP_PACK_DS(val,X)			\
-	fp_pack_ds(val, X##_s, X##_f1, X##_f0, X##_e, X##_c)
-
-/* Obtain the current rounding mode. */
-#define FP_ROUNDMODE			\
-({					\
-	__FPU_FPSCR & 0x3;		\
-})
-
 /* the asm fragments go here: all these are taken from glibc-2.0.5's
  * stdlib/longlong.h
  */
@@ -359,13 +246,49 @@ extern int  fp_pack_ds(void *, long, unsigned long, unsigned long, long, long);
 #define __BYTE_ORDER __LITTLE_ENDIAN
 #endif
 
+#include <linux/kernel.h>
+#include <linux/sched.h>
+
+#define __FPU_FPSCR	(current->thread.fpscr.val)
+
+/* We only actually write to the destination register
+ * if exceptions signalled (if any) will not trap.
+ */
+#define __FPU_ENABLED_EXC \
+({						\
+	(__FPU_FPSCR >> 3) & 0x1f;	\
+})
+
+#define __FPU_TRAP_P(bits) \
+	((__FPU_ENABLED_EXC & (bits)) != 0)
+
+#define __FP_PACK_DS(val,X)			\
+  do {						\
+    FP_DECL_S(__X);				\
+    FP_CONV(S, D, 1, 2, __X, X);		\
+    _FP_PACK_CANONICAL(S, 1, __X);		\
+    if (!FP_INHIBIT_RESULTS) {			\
+      _FP_UNPACK_CANONICAL(S, 1, __X);		\
+      FP_CONV(D, S, 2, 1, X, __X);		\
+      _FP_PACK_CANONICAL(D, 2, X);		\
+        if (!FP_INHIBIT_RESULTS) {		\
+          _FP_PACK_RAW_2_P(D,val,X);		\
+	}					\
+    }						\
+  } while (0)
+
+/* Obtain the current rounding mode. */
+#define FP_ROUNDMODE			\
+({					\
+	__FPU_FPSCR & 0x3;		\
+})
+
 /* Exception flags. */
 #define EFLAG_INVALID		(1 << (31 - 2))
 #define EFLAG_OVERFLOW		(1 << (31 - 3))
 #define EFLAG_UNDERFLOW		(1 << (31 - 4))
 #define EFLAG_DIVZERO		(1 << (31 - 5))
 #define EFLAG_INEXACT		(1 << (31 - 6))
-
 #define EFLAG_VXSNAN		(1 << (31 - 7))
 #define EFLAG_VXISI		(1 << (31 - 8))
 #define EFLAG_VXIDI		(1 << (31 - 9))
@@ -375,3 +298,13 @@ extern int  fp_pack_ds(void *, long, unsigned long, unsigned long, long, long);
 #define EFLAG_VXSOFT		(1 << (31 - 21))
 #define EFLAG_VXSQRT		(1 << (31 - 22))
 #define EFLAG_VXCVI		(1 << (31 - 23))
+
+#define FP_EX_INVALID           EFLAG_INVALID
+#define FP_EX_DIVZERO           EFLAG_DIVZERO
+#define FP_EX_OVERFLOW          EFLAG_OVERFLOW
+#define FP_EX_UNDERFLOW         EFLAG_UNDERFLOW
+#define FP_EX_INEXACT           EFLAG_INEXACT
+#define FP_INHIBIT_RESULTS	(!FP_CUR_EXCEPTIONS || !__FPU_TRAP_P(FP_CUR_EXCEPTIONS))
+
+#define FP_TRAPPING_EXCEPTIONS	__FPU_ENABLED_EXC
+
Signature · 1 line
1.5.2
author
#2 lore raw

PATCH 1/1 math-emu: use new interface of common math-emu headers in PowerPC math-emu C file

---
 arch/powerpc/math-emu/Makefile     |    2 +-
 arch/powerpc/math-emu/fadd.c       |   16 +++++++++-------
 arch/powerpc/math-emu/fadds.c      |   17 +++++++++--------
 arch/powerpc/math-emu/fcmpo.c      |   22 +++++++++++++---------
 arch/powerpc/math-emu/fcmpu.c      |   20 +++++++++++++-------
 arch/powerpc/math-emu/fctiw.c      |    9 +++++----
 arch/powerpc/math-emu/fctiwz.c     |    9 +++++----
 arch/powerpc/math-emu/fdiv.c       |   22 +++++++++-------------
 arch/powerpc/math-emu/fdivs.c      |   25 ++++++++++---------------
 arch/powerpc/math-emu/fmadd.c      |   19 ++++++++++---------
 arch/powerpc/math-emu/fmadds.c     |   21 +++++++++++----------
 arch/powerpc/math-emu/fmsub.c      |   19 ++++++++++---------
 arch/powerpc/math-emu/fmsubs.c     |   21 +++++++++++----------
 arch/powerpc/math-emu/fmul.c       |   15 ++++++++-------
 arch/powerpc/math-emu/fmuls.c      |   17 +++++++++--------
 arch/powerpc/math-emu/fnmadd.c     |   19 ++++++++++---------
 arch/powerpc/math-emu/fnmadds.c    |   21 +++++++++++----------
 arch/powerpc/math-emu/fnmsub.c     |   19 ++++++++++---------
 arch/powerpc/math-emu/fnmsubs.c    |   21 +++++++++++----------
 arch/powerpc/math-emu/frsp.c       |   12 +++++++-----
 arch/powerpc/math-emu/fsel.c       |    9 +++++----
 arch/powerpc/math-emu/fsqrt.c      |   15 ++++++++-------
 arch/powerpc/math-emu/fsqrts.c     |   17 +++++++++--------
 arch/powerpc/math-emu/fsub.c       |   15 ++++++++-------
 arch/powerpc/math-emu/fsubs.c      |   17 +++++++++--------
 arch/powerpc/math-emu/lfd.c        |    4 ++--
 arch/powerpc/math-emu/lfs.c        |   12 +++++++-----
 arch/powerpc/math-emu/math.c       |    4 ++--
 arch/powerpc/math-emu/mcrfs.c      |    2 +-
 arch/powerpc/math-emu/mffs.c       |    2 +-
 arch/powerpc/math-emu/mtfsb0.c     |    2 +-
 arch/powerpc/math-emu/mtfsb1.c     |    2 +-
 arch/powerpc/math-emu/mtfsf.c      |    2 +-
 arch/powerpc/math-emu/mtfsfi.c     |    2 +-
 arch/powerpc/math-emu/stfs.c       |   18 +++++++++---------
 arch/powerpc/math-emu/udivmodti4.c |    2 +-
 36 files changed, 248 insertions(+), 223 deletions(-)
arch/powerpc/math-emu/Makefile +1 -1
index 29bc912..578c39a 100644
@@ -4,7 +4,7 @@ obj-y				:= math.o fmr.o lfd.o stfd.o
 obj-$(CONFIG_MATH_EMULATION)	+= fabs.o fadd.o fadds.o fcmpo.o fcmpu.o \
 					fctiw.o fctiwz.o fdiv.o fdivs.o \
 					fmadd.o fmadds.o fmsub.o fmsubs.o \
-					fmul.o fmuls.o fnabs.o fneg.o types.o \
+					fmul.o fmuls.o fnabs.o fneg.o \
 					fnmadd.o fnmadds.o fnmsub.o fnmsubs.o \
 					fres.o frsp.o frsqrte.o fsel.o lfs.o \
 					fsqrt.o	fsqrts.o fsub.o fsubs.o \
arch/powerpc/math-emu/fadd.c +9 -7
index fc88364..18643ea 100644
@@ -2,23 +2,23 @@
 #include <linux/errno.h>
 #include <asm/uaccess.h>
 
-#include "soft-fp.h"
-#include "double.h"
+#include <math-emu/soft-fp.h>
+#include <math-emu/double.h>
 
 int
 fadd(void *frD, void *frA, void *frB)
 {
+	FP_DECL_EX;
 	FP_DECL_D(A);
 	FP_DECL_D(B);
 	FP_DECL_D(R);
-	int ret = 0;
 
 #ifdef DEBUG
 	printk("%s: %p %p %p\n", __FUNCTION__, frD, frA, frB);
 #endif
 
-	__FP_UNPACK_D(A, frA);
-	__FP_UNPACK_D(B, frB);
+	FP_UNPACK_DP(A, frA);
+	FP_UNPACK_DP(B, frB);
 
 #ifdef DEBUG
 	printk("A: %ld %lu %lu %ld (%ld)\n", A_s, A_f1, A_f0, A_e, A_c);
@@ -26,7 +26,7 @@ fadd(void *frD, void *frA, void *frB)
 #endif
 
 	if (A_s != B_s && A_c == FP_CLS_INF && B_c == FP_CLS_INF)
-		ret |= EFLAG_VXISI;
+		FP_SET_EXCEPTION(EFLAG_VXISI);
 
 	FP_ADD_D(R, A, B);
 
@@ -34,5 +34,7 @@ fadd(void *frD, void *frA, void *frB)
 	printk("D: %ld %lu %lu %ld (%ld)\n", R_s, R_f1, R_f0, R_e, R_c);
 #endif
 
-	return (ret | __FP_PACK_D(frD, R));
+	FP_PACK_DP(frD, R);
+
+	return FP_CUR_EXCEPTIONS;
 }
arch/powerpc/math-emu/fadds.c +9 -8
index 93025b6..2b4fe58 100644
@@ -2,24 +2,24 @@
 #include <linux/errno.h>
 #include <asm/uaccess.h>
 
-#include "soft-fp.h"
-#include "double.h"
-#include "single.h"
+#include <math-emu/soft-fp.h>
+#include <math-emu/double.h>
+#include <math-emu/single.h>
 
 int
 fadds(void *frD, void *frA, void *frB)
 {
+	FP_DECL_EX;
 	FP_DECL_D(A);
 	FP_DECL_D(B);
 	FP_DECL_D(R);
-	int ret = 0;
 
 #ifdef DEBUG
 	printk("%s: %p %p %p\n", __FUNCTION__, frD, frA, frB);
 #endif
 
-	__FP_UNPACK_D(A, frA);
-	__FP_UNPACK_D(B, frB);
+	FP_UNPACK_DP(A, frA);
+	FP_UNPACK_DP(B, frB);
 
 #ifdef DEBUG
 	printk("A: %ld %lu %lu %ld (%ld)\n", A_s, A_f1, A_f0, A_e, A_c);
@@ -27,13 +27,14 @@ fadds(void *frD, void *frA, void *frB)
 #endif
 
 	if (A_s != B_s && A_c == FP_CLS_INF && B_c == FP_CLS_INF)
-		ret |= EFLAG_VXISI;
+		FP_SET_EXCEPTION(EFLAG_VXISI);
 
 	FP_ADD_D(R, A, B);
 
 #ifdef DEBUG
 	printk("D: %ld %lu %lu %ld (%ld)\n", R_s, R_f1, R_f0, R_e, R_c);
 #endif
+	__FP_PACK_DS(frD, R);
 
-	return (ret | __FP_PACK_DS(frD, R));
+	return FP_CUR_EXCEPTIONS;
 }
arch/powerpc/math-emu/fcmpo.c +13 -9
index 4efac39..adcc4b4 100644
@@ -2,24 +2,24 @@
 #include <linux/errno.h>
 #include <asm/uaccess.h>
 
-#include "soft-fp.h"
-#include "double.h"
+#include <math-emu/soft-fp.h>
+#include <math-emu/double.h>
 
 int
 fcmpo(u32 *ccr, int crfD, void *frA, void *frB)
 {
+	FP_DECL_EX;
 	FP_DECL_D(A);
 	FP_DECL_D(B);
 	int code[4] = { (1 << 3), (1 << 1), (1 << 2), (1 << 0) };
 	long cmp;
-	int ret = 0;
 
 #ifdef DEBUG
 	printk("%s: %p (%08x) %d %p %p\n", __FUNCTION__, ccr, *ccr, crfD, frA, frB);
 #endif
 
-	__FP_UNPACK_D(A, frA);
-	__FP_UNPACK_D(B, frB);
+	FP_UNPACK_DP(A, frA);
+	FP_UNPACK_DP(B, frB);
 
 #ifdef DEBUG
 	printk("A: %ld %lu %lu %ld (%ld)\n", A_s, A_f1, A_f0, A_e, A_c);
@@ -27,10 +27,14 @@ fcmpo(u32 *ccr, int crfD, void *frA, void *frB)
 #endif
 
 	if (A_c == FP_CLS_NAN || B_c == FP_CLS_NAN)
-		ret |= EFLAG_VXVC;
+		FP_SET_EXCEPTION(EFLAG_VXVC);
 
-	FP_CMP_D(cmp, A, B, 2);
-	cmp = code[(cmp + 1) & 3];
+	FP_CMP_D(cmp, A, B, 3);
+	if (cmp == 3 && (FP_ISSIGNAN_D(A) || FP_ISSIGNAN_D(B))){
+		FP_SET_EXCEPTION (FP_EX_INVALID);
+		cmp = 1;
+	} else
+		cmp = code[(cmp + 1) & 3];
 
 	__FPU_FPSCR &= ~(0x1f000);
 	__FPU_FPSCR |= (cmp << 12);
@@ -42,5 +46,5 @@ fcmpo(u32 *ccr, int crfD, void *frA, void *frB)
 	printk("CR: %08x\n", *ccr);
 #endif
 
-	return ret;
+	return FP_CUR_EXCEPTIONS;
 }
arch/powerpc/math-emu/fcmpu.c +13 -7
index b7e3317..8f91e0b 100644
@@ -2,12 +2,13 @@
 #include <linux/errno.h>
 #include <asm/uaccess.h>
 
-#include "soft-fp.h"
-#include "double.h"
+#include <math-emu/soft-fp.h>
+#include <math-emu/double.h>
 
 int
 fcmpu(u32 *ccr, int crfD, void *frA, void *frB)
 {
+	FP_DECL_EX;
 	FP_DECL_D(A);
 	FP_DECL_D(B);
 	int code[4] = { (1 << 3), (1 << 1), (1 << 2), (1 << 0) };
@@ -17,16 +18,21 @@ fcmpu(u32 *ccr, int crfD, void *frA, void *frB)
 	printk("%s: %p (%08x) %d %p %p\n", __FUNCTION__, ccr, *ccr, crfD, frA, frB);
 #endif
 
-	__FP_UNPACK_D(A, frA);
-	__FP_UNPACK_D(B, frB);
+	FP_UNPACK_DP(A, frA);
+	FP_UNPACK_DP(B, frB);
 
 #ifdef DEBUG
 	printk("A: %ld %lu %lu %ld (%ld)\n", A_s, A_f1, A_f0, A_e, A_c);
 	printk("B: %ld %lu %lu %ld (%ld)\n", B_s, B_f1, B_f0, B_e, B_c);
 #endif
 
-	FP_CMP_D(cmp, A, B, 2);
-	cmp = code[(cmp + 1) & 3];
+	FP_CMP_D(cmp, A, B, 3);
+	if (cmp == 3 && (FP_ISSIGNAN_D(A) || FP_ISSIGNAN_D(B))){
+		FP_SET_EXCEPTION (FP_EX_INVALID);
+		cmp = 1;
+	} else
+		cmp = code[(cmp + 1) & 3];
+
 
 	__FPU_FPSCR &= ~(0x1f000);
 	__FPU_FPSCR |= (cmp << 12);
@@ -38,5 +44,5 @@ fcmpu(u32 *ccr, int crfD, void *frA, void *frB)
 	printk("CR: %08x\n", *ccr);
 #endif
 
-	return 0;
+	return FP_CUR_EXCEPTIONS;
 }
arch/powerpc/math-emu/fctiw.c +5 -4
index 3b3c98b..f0ae59d 100644
@@ -2,16 +2,17 @@
 #include <linux/errno.h>
 #include <asm/uaccess.h>
 
-#include "soft-fp.h"
-#include "double.h"
+#include <math-emu/soft-fp.h>
+#include <math-emu/double.h>
 
 int
 fctiw(u32 *frD, void *frB)
 {
+	FP_DECL_EX;
 	FP_DECL_D(B);
 	unsigned int r;
 
-	__FP_UNPACK_D(B, frB);
+	FP_UNPACK_DP(B, frB);
 	FP_TO_INT_D(r, B, 32, 1);
 	frD[1] = r;
 
@@ -21,5 +22,5 @@ fctiw(u32 *frD, void *frB)
 	printk("\n");
 #endif
 
-	return 0;
+	return FP_CUR_EXCEPTIONS;
 }
arch/powerpc/math-emu/fctiwz.c +5 -4
index 7717eb6..7dfdd9e 100644
@@ -2,12 +2,13 @@
 #include <linux/errno.h>
 #include <asm/uaccess.h>
 
-#include "soft-fp.h"
-#include "double.h"
+#include <math-emu/soft-fp.h>
+#include <math-emu/double.h>
 
 int
 fctiwz(u32 *frD, void *frB)
 {
+	FP_DECL_EX;
 	FP_DECL_D(B);
 	u32 fpscr;
 	unsigned int r;
@@ -16,7 +17,7 @@ fctiwz(u32 *frD, void *frB)
 	__FPU_FPSCR &= ~(3);
 	__FPU_FPSCR |= FP_RND_ZERO;
 
-	__FP_UNPACK_D(B, frB);
+	FP_UNPACK_DP(B, frB);
 	FP_TO_INT_D(r, B, 32, 1);
 	frD[1] = r;
 
@@ -28,5 +29,5 @@ fctiwz(u32 *frD, void *frB)
 	printk("\n");
 #endif
 
-	return 0;
+	return FP_CUR_EXCEPTIONS;
 }
arch/powerpc/math-emu/fdiv.c +9 -13
index f2fba82..371d4da 100644
@@ -2,23 +2,23 @@
 #include <linux/errno.h>
 #include <asm/uaccess.h>
 
-#include "soft-fp.h"
-#include "double.h"
+#include <math-emu/soft-fp.h>
+#include <math-emu/double.h>
 
 int
 fdiv(void *frD, void *frA, void *frB)
 {
+	FP_DECL_EX;
 	FP_DECL_D(A);
 	FP_DECL_D(B);
 	FP_DECL_D(R);
-	int ret = 0;
 
 #ifdef DEBUG
 	printk("%s: %p %p %p\n", __FUNCTION__, frD, frA, frB);
 #endif
 
-	__FP_UNPACK_D(A, frA);
-	__FP_UNPACK_D(B, frB);
+	FP_UNPACK_DP(A, frA);
+	FP_UNPACK_DP(B, frB);
 
 #ifdef DEBUG
 	printk("A: %ld %lu %lu %ld (%ld)\n", A_s, A_f1, A_f0, A_e, A_c);
@@ -26,28 +26,24 @@ fdiv(void *frD, void *frA, void *frB)
 #endif
 
 	if (A_c == FP_CLS_ZERO && B_c == FP_CLS_ZERO) {
-		ret |= EFLAG_VXZDZ;
+		FP_SET_EXCEPTION(EFLAG_VXZDZ);
 #ifdef DEBUG
 		printk("%s: FPSCR_VXZDZ raised\n", __FUNCTION__);
 #endif
 	}
 	if (A_c == FP_CLS_INF && B_c == FP_CLS_INF) {
-		ret |= EFLAG_VXIDI;
+		FP_SET_EXCEPTION(EFLAG_VXIDI);
 #ifdef DEBUG
 		printk("%s: FPSCR_VXIDI raised\n", __FUNCTION__);
 #endif
 	}
 
-	if (B_c == FP_CLS_ZERO && A_c != FP_CLS_ZERO) {
-		ret |= EFLAG_DIVZERO;
-		if (__FPU_TRAP_P(EFLAG_DIVZERO))
-			return ret;
-	}
 	FP_DIV_D(R, A, B);
 
 #ifdef DEBUG
 	printk("D: %ld %lu %lu %ld (%ld)\n", R_s, R_f1, R_f0, R_e, R_c);
 #endif
+	FP_PACK_DP(frD, R);
 
-	return (ret | __FP_PACK_D(frD, R));
+	return FP_CUR_EXCEPTIONS;
 }
arch/powerpc/math-emu/fdivs.c +10 -15
index b971196..2dbd79d 100644
@@ -2,24 +2,24 @@
 #include <linux/errno.h>
 #include <asm/uaccess.h>
 
-#include "soft-fp.h"
-#include "double.h"
-#include "single.h"
+#include <math-emu/soft-fp.h>
+#include <math-emu/double.h>
+#include <math-emu/single.h>
 
 int
 fdivs(void *frD, void *frA, void *frB)
 {
+	FP_DECL_EX;
 	FP_DECL_D(A);
 	FP_DECL_D(B);
 	FP_DECL_D(R);
-	int ret = 0;
 
 #ifdef DEBUG
 	printk("%s: %p %p %p\n", __FUNCTION__, frD, frA, frB);
 #endif
 
-	__FP_UNPACK_D(A, frA);
-	__FP_UNPACK_D(B, frB);
+	FP_UNPACK_DP(A, frA);
+	FP_UNPACK_DP(B, frB);
 
 #ifdef DEBUG
 	printk("A: %ld %lu %lu %ld (%ld)\n", A_s, A_f1, A_f0, A_e, A_c);
@@ -27,29 +27,24 @@ fdivs(void *frD, void *frA, void *frB)
 #endif
 
 	if (A_c == FP_CLS_ZERO && B_c == FP_CLS_ZERO) {
-		ret |= EFLAG_VXZDZ;
+		FP_SET_EXCEPTION(EFLAG_VXZDZ);
 #ifdef DEBUG
 		printk("%s: FPSCR_VXZDZ raised\n", __FUNCTION__);
 #endif
 	}
 	if (A_c == FP_CLS_INF && B_c == FP_CLS_INF) {
-		ret |= EFLAG_VXIDI;
+		FP_SET_EXCEPTION(EFLAG_VXIDI);
 #ifdef DEBUG
 		printk("%s: FPSCR_VXIDI raised\n", __FUNCTION__);
 #endif
 	}
 
-	if (B_c == FP_CLS_ZERO && A_c != FP_CLS_ZERO) {
-		ret |= EFLAG_DIVZERO;
-		if (__FPU_TRAP_P(EFLAG_DIVZERO))
-			return ret;
-	}
-
 	FP_DIV_D(R, A, B);
 
 #ifdef DEBUG
 	printk("D: %ld %lu %lu %ld (%ld)\n", R_s, R_f1, R_f0, R_e, R_c);
 #endif
+	__FP_PACK_DS(frD, R);
 
-	return (ret | __FP_PACK_DS(frD, R));
+	return FP_CUR_EXCEPTIONS;
 }
arch/powerpc/math-emu/fmadd.c +10 -9
index 0a1dbce..06f49ff 100644
@@ -2,26 +2,26 @@
 #include <linux/errno.h>
 #include <asm/uaccess.h>
 
-#include "soft-fp.h"
-#include "double.h"
+#include <math-emu/soft-fp.h>
+#include <math-emu/double.h>
 
 int
 fmadd(void *frD, void *frA, void *frB, void *frC)
 {
+	FP_DECL_EX;
 	FP_DECL_D(R);
 	FP_DECL_D(A);
 	FP_DECL_D(B);
 	FP_DECL_D(C);
 	FP_DECL_D(T);
-	int ret = 0;
 
 #ifdef DEBUG
 	printk("%s: %p %p %p %p\n", __FUNCTION__, frD, frA, frB, frC);
 #endif
 
-	__FP_UNPACK_D(A, frA);
-	__FP_UNPACK_D(B, frB);
-	__FP_UNPACK_D(C, frC);
+	FP_UNPACK_DP(A, frA);
+	FP_UNPACK_DP(B, frB);
+	FP_UNPACK_DP(C, frC);
 
 #ifdef DEBUG
 	printk("A: %ld %lu %lu %ld (%ld)\n", A_s, A_f1, A_f0, A_e, A_c);
@@ -31,18 +31,19 @@ fmadd(void *frD, void *frA, void *frB, void *frC)
 
 	if ((A_c == FP_CLS_INF && C_c == FP_CLS_ZERO) ||
 	    (A_c == FP_CLS_ZERO && C_c == FP_CLS_INF))
-                ret |= EFLAG_VXIMZ;
+                FP_SET_EXCEPTION(EFLAG_VXIMZ);
 
 	FP_MUL_D(T, A, C);
 
 	if (T_s != B_s && T_c == FP_CLS_INF && B_c == FP_CLS_INF)
-		ret |= EFLAG_VXISI;
+		FP_SET_EXCEPTION(EFLAG_VXISI);
 
 	FP_ADD_D(R, T, B);
 
 #ifdef DEBUG
 	printk("D: %ld %lu %lu %ld (%ld)\n", R_s, R_f1, R_f0, R_e, R_c);
 #endif
+	FP_PACK_DP(frD, R);
 
-	return (ret | __FP_PACK_D(frD, R));
+	return FP_CUR_EXCEPTIONS;
 }
arch/powerpc/math-emu/fmadds.c +11 -10
index 0f70bba..ef0bac0 100644
@@ -2,27 +2,27 @@
 #include <linux/errno.h>
 #include <asm/uaccess.h>
 
-#include "soft-fp.h"
-#include "double.h"
-#include "single.h"
+#include <math-emu/soft-fp.h>
+#include <math-emu/double.h>
+#include <math-emu/single.h>
 
 int
 fmadds(void *frD, void *frA, void *frB, void *frC)
 {
+	FP_DECL_EX;
 	FP_DECL_D(R);
 	FP_DECL_D(A);
 	FP_DECL_D(B);
 	FP_DECL_D(C);
 	FP_DECL_D(T);
-	int ret = 0;
 
 #ifdef DEBUG
 	printk("%s: %p %p %p %p\n", __FUNCTION__, frD, frA, frB, frC);
 #endif
 
-	__FP_UNPACK_D(A, frA);
-	__FP_UNPACK_D(B, frB);
-	__FP_UNPACK_D(C, frC);
+	FP_UNPACK_DP(A, frA);
+	FP_UNPACK_DP(B, frB);
+	FP_UNPACK_DP(C, frC);
 
 #ifdef DEBUG
 	printk("A: %ld %lu %lu %ld (%ld)\n", A_s, A_f1, A_f0, A_e, A_c);
@@ -32,18 +32,19 @@ fmadds(void *frD, void *frA, void *frB, void *frC)
 
 	if ((A_c == FP_CLS_INF && C_c == FP_CLS_ZERO) ||
 	    (A_c == FP_CLS_ZERO && C_c == FP_CLS_INF))
-                ret |= EFLAG_VXIMZ;
+                FP_SET_EXCEPTION(EFLAG_VXIMZ);
 
 	FP_MUL_D(T, A, C);
 
 	if (T_s != B_s && T_c == FP_CLS_INF && B_c == FP_CLS_INF)
-		ret |= EFLAG_VXISI;
+		FP_SET_EXCEPTION(EFLAG_VXISI);
 
 	FP_ADD_D(R, T, B);
 
 #ifdef DEBUG
 	printk("D: %ld %lu %lu %ld (%ld)\n", R_s, R_f1, R_f0, R_e, R_c);
 #endif
+	__FP_PACK_DS(frD, R);
 
-	return (ret | __FP_PACK_DS(frD, R));
+	return FP_CUR_EXCEPTIONS;
 }
arch/powerpc/math-emu/fmsub.c +10 -9
index 203fd48..55c851e 100644
@@ -2,26 +2,26 @@
 #include <linux/errno.h>
 #include <asm/uaccess.h>
 
-#include "soft-fp.h"
-#include "double.h"
+#include <math-emu/soft-fp.h>
+#include <math-emu/double.h>
 
 int
 fmsub(void *frD, void *frA, void *frB, void *frC)
 {
+	FP_DECL_EX;
 	FP_DECL_D(R);
 	FP_DECL_D(A);
 	FP_DECL_D(B);
 	FP_DECL_D(C);
 	FP_DECL_D(T);
-	int ret = 0;
 
 #ifdef DEBUG
 	printk("%s: %p %p %p %p\n", __FUNCTION__, frD, frA, frB, frC);
 #endif
 
-	__FP_UNPACK_D(A, frA);
-	__FP_UNPACK_D(B, frB);
-	__FP_UNPACK_D(C, frC);
+	FP_UNPACK_DP(A, frA);
+	FP_UNPACK_DP(B, frB);
+	FP_UNPACK_DP(C, frC);
 
 #ifdef DEBUG
 	printk("A: %ld %lu %lu %ld (%ld)\n", A_s, A_f1, A_f0, A_e, A_c);
@@ -31,7 +31,7 @@ fmsub(void *frD, void *frA, void *frB, void *frC)
 
 	if ((A_c == FP_CLS_INF && C_c == FP_CLS_ZERO) ||
 	    (A_c == FP_CLS_ZERO && C_c == FP_CLS_INF))
-		ret |= EFLAG_VXIMZ;
+		FP_SET_EXCEPTION(EFLAG_VXIMZ);
 
 	FP_MUL_D(T, A, C);
 
@@ -39,13 +39,14 @@ fmsub(void *frD, void *frA, void *frB, void *frC)
 		B_s ^= 1;
 
 	if (T_s != B_s && T_c == FP_CLS_INF && B_c == FP_CLS_INF)
-		ret |= EFLAG_VXISI;
+		FP_SET_EXCEPTION(EFLAG_VXISI);
 
 	FP_ADD_D(R, T, B);
 
 #ifdef DEBUG
 	printk("D: %ld %lu %lu %ld (%ld)\n", R_s, R_f1, R_f0, R_e, R_c);
 #endif
+	FP_PACK_DP(frD, R);
 
-	return (ret | __FP_PACK_D(frD, R));
+	return FP_CUR_EXCEPTIONS;
 }
arch/powerpc/math-emu/fmsubs.c +11 -10
index 8ce6862..81941df 100644
@@ -2,27 +2,27 @@
 #include <linux/errno.h>
 #include <asm/uaccess.h>
 
-#include "soft-fp.h"
-#include "double.h"
-#include "single.h"
+#include <math-emu/soft-fp.h>
+#include <math-emu/double.h>
+#include <math-emu/single.h>
 
 int
 fmsubs(void *frD, void *frA, void *frB, void *frC)
 {
+	FP_DECL_EX;
 	FP_DECL_D(R);
 	FP_DECL_D(A);
 	FP_DECL_D(B);
 	FP_DECL_D(C);
 	FP_DECL_D(T);
-	int ret = 0;
 
 #ifdef DEBUG
 	printk("%s: %p %p %p %p\n", __FUNCTION__, frD, frA, frB, frC);
 #endif
 
-	__FP_UNPACK_D(A, frA);
-	__FP_UNPACK_D(B, frB);
-	__FP_UNPACK_D(C, frC);
+	FP_UNPACK_DP(A, frA);
+	FP_UNPACK_DP(B, frB);
+	FP_UNPACK_DP(C, frC);
 
 #ifdef DEBUG
 	printk("A: %ld %lu %lu %ld (%ld)\n", A_s, A_f1, A_f0, A_e, A_c);
@@ -32,7 +32,7 @@ fmsubs(void *frD, void *frA, void *frB, void *frC)
 
 	if ((A_c == FP_CLS_INF && C_c == FP_CLS_ZERO) ||
 	    (A_c == FP_CLS_ZERO && C_c == FP_CLS_INF))
-		ret |= EFLAG_VXIMZ;
+		FP_SET_EXCEPTION(EFLAG_VXIMZ);
 
 	FP_MUL_D(T, A, C);
 
@@ -40,13 +40,14 @@ fmsubs(void *frD, void *frA, void *frB, void *frC)
 		B_s ^= 1;
 
 	if (T_s != B_s && T_c == FP_CLS_INF && B_c == FP_CLS_INF)
-		ret |= EFLAG_VXISI;
+		FP_SET_EXCEPTION(EFLAG_VXISI);
 
 	FP_ADD_D(R, T, B);
 
 #ifdef DEBUG
 	printk("D: %ld %lu %lu %ld (%ld)\n", R_s, R_f1, R_f0, R_e, R_c);
 #endif
+	__FP_PACK_DS(frD, R);
 
-	return (ret | __FP_PACK_DS(frD, R));
+	return FP_CUR_EXCEPTIONS;
 }
arch/powerpc/math-emu/fmul.c +8 -7
index 66c7e79..6f44699 100644
@@ -2,23 +2,23 @@
 #include <linux/errno.h>
 #include <asm/uaccess.h>
 
-#include "soft-fp.h"
-#include "double.h"
+#include <math-emu/soft-fp.h>
+#include <math-emu/double.h>
 
 int
 fmul(void *frD, void *frA, void *frB)
 {
+	FP_DECL_EX;
 	FP_DECL_D(A);
 	FP_DECL_D(B);
 	FP_DECL_D(R);
-	int ret = 0;
 
 #ifdef DEBUG
 	printk("%s: %p %p %p\n", __FUNCTION__, frD, frA, frB);
 #endif
 
-	__FP_UNPACK_D(A, frA);
-	__FP_UNPACK_D(B, frB);
+	FP_UNPACK_DP(A, frA);
+	FP_UNPACK_DP(B, frB);
 
 #ifdef DEBUG
 	printk("A: %ld %lu %lu %ld (%ld) [%08lx.%08lx %lx]\n",
@@ -29,7 +29,7 @@ fmul(void *frD, void *frA, void *frB)
 
 	if ((A_c == FP_CLS_INF && B_c == FP_CLS_ZERO) ||
 	    (A_c == FP_CLS_ZERO && B_c == FP_CLS_INF))
-		ret |= EFLAG_VXIMZ;
+		FP_SET_EXCEPTION(EFLAG_VXIMZ);
 
 	FP_MUL_D(R, A, B);
 
@@ -37,6 +37,7 @@ fmul(void *frD, void *frA, void *frB)
 	printk("D: %ld %lu %lu %ld (%ld) [%08lx.%08lx %lx]\n",
 	       R_s, R_f1, R_f0, R_e, R_c, R_f1, R_f0, R_e + 1023);
 #endif
+	FP_PACK_DP(frD, R);
 
-	return (ret | __FP_PACK_D(frD, R));
+	return FP_CUR_EXCEPTIONS;
 }
arch/powerpc/math-emu/fmuls.c +9 -8
index 26bc427..6035a10 100644
@@ -2,24 +2,24 @@
 #include <linux/errno.h>
 #include <asm/uaccess.h>
 
-#include "soft-fp.h"
-#include "double.h"
-#include "single.h"
+#include <math-emu/soft-fp.h>
+#include <math-emu/double.h>
+#include <math-emu/single.h>
 
 int
 fmuls(void *frD, void *frA, void *frB)
 {
+	FP_DECL_EX;
 	FP_DECL_D(A);
 	FP_DECL_D(B);
 	FP_DECL_D(R);
-	int ret = 0;
 
 #ifdef DEBUG
 	printk("%s: %p %p %p\n", __FUNCTION__, frD, frA, frB);
 #endif
 
-	__FP_UNPACK_D(A, frA);
-	__FP_UNPACK_D(B, frB);
+	FP_UNPACK_DP(A, frA);
+	FP_UNPACK_DP(B, frB);
 
 #ifdef DEBUG
 	printk("A: %ld %lu %lu %ld (%ld) [%08lx.%08lx %lx]\n",
@@ -30,7 +30,7 @@ fmuls(void *frD, void *frA, void *frB)
 
 	if ((A_c == FP_CLS_INF && B_c == FP_CLS_ZERO) ||
 	    (A_c == FP_CLS_ZERO && B_c == FP_CLS_INF))
-		ret |= EFLAG_VXIMZ;
+		FP_SET_EXCEPTION(EFLAG_VXIMZ);
 
 	FP_MUL_D(R, A, B);
 
@@ -38,6 +38,7 @@ fmuls(void *frD, void *frA, void *frB)
 	printk("D: %ld %lu %lu %ld (%ld) [%08lx.%08lx %lx]\n",
 	       R_s, R_f1, R_f0, R_e, R_c, R_f1, R_f0, R_e + 1023);
 #endif
+	__FP_PACK_DS(frD, R);
 
-	return (ret | __FP_PACK_DS(frD, R));
+	return FP_CUR_EXCEPTIONS;
 }
arch/powerpc/math-emu/fnmadd.c +10 -9
index 7f31227..8741b56 100644
@@ -2,26 +2,26 @@
 #include <linux/errno.h>
 #include <asm/uaccess.h>
 
-#include "soft-fp.h"
-#include "double.h"
+#include <math-emu/soft-fp.h>
+#include <math-emu/double.h>
 
 int
 fnmadd(void *frD, void *frA, void *frB, void *frC)
 {
+	FP_DECL_EX;
 	FP_DECL_D(R);
 	FP_DECL_D(A);
 	FP_DECL_D(B);
 	FP_DECL_D(C);
 	FP_DECL_D(T);
-	int ret = 0;
 
 #ifdef DEBUG
 	printk("%s: %p %p %p %p\n", __FUNCTION__, frD, frA, frB, frC);
 #endif
 
-	__FP_UNPACK_D(A, frA);
-	__FP_UNPACK_D(B, frB);
-	__FP_UNPACK_D(C, frC);
+	FP_UNPACK_DP(A, frA);
+	FP_UNPACK_DP(B, frB);
+	FP_UNPACK_DP(C, frC);
 
 #ifdef DEBUG
 	printk("A: %ld %lu %lu %ld (%ld)\n", A_s, A_f1, A_f0, A_e, A_c);
@@ -31,12 +31,12 @@ fnmadd(void *frD, void *frA, void *frB, void *frC)
 
 	if ((A_c == FP_CLS_INF && C_c == FP_CLS_ZERO) ||
 	    (A_c == FP_CLS_ZERO && C_c == FP_CLS_INF))
-                ret |= EFLAG_VXIMZ;
+                FP_SET_EXCEPTION(EFLAG_VXIMZ);
 
 	FP_MUL_D(T, A, C);
 
 	if (T_s != B_s && T_c == FP_CLS_INF && B_c == FP_CLS_INF)
-		ret |= EFLAG_VXISI;
+		FP_SET_EXCEPTION(EFLAG_VXISI);
 
 	FP_ADD_D(R, T, B);
 
@@ -46,6 +46,7 @@ fnmadd(void *frD, void *frA, void *frB, void *frC)
 #ifdef DEBUG
 	printk("D: %ld %lu %lu %ld (%ld)\n", R_s, R_f1, R_f0, R_e, R_c);
 #endif
+	FP_PACK_DP(frD, R);
 
-	return (ret | __FP_PACK_D(frD, R));
+	return FP_CUR_EXCEPTIONS;
 }
arch/powerpc/math-emu/fnmadds.c +11 -10
index 65454c9..d04d4aa 100644
@@ -2,27 +2,27 @@
 #include <linux/errno.h>
 #include <asm/uaccess.h>
 
-#include "soft-fp.h"
-#include "double.h"
-#include "single.h"
+#include <math-emu/soft-fp.h>
+#include <math-emu/double.h>
+#include <math-emu/single.h>
 
 int
 fnmadds(void *frD, void *frA, void *frB, void *frC)
 {
+	FP_DECL_EX;
 	FP_DECL_D(R);
 	FP_DECL_D(A);
 	FP_DECL_D(B);
 	FP_DECL_D(C);
 	FP_DECL_D(T);
-	int ret = 0;
 
 #ifdef DEBUG
 	printk("%s: %p %p %p %p\n", __FUNCTION__, frD, frA, frB, frC);
 #endif
 
-	__FP_UNPACK_D(A, frA);
-	__FP_UNPACK_D(B, frB);
-	__FP_UNPACK_D(C, frC);
+	FP_UNPACK_DP(A, frA);
+	FP_UNPACK_DP(B, frB);
+	FP_UNPACK_DP(C, frC);
 
 #ifdef DEBUG
 	printk("A: %ld %lu %lu %ld (%ld)\n", A_s, A_f1, A_f0, A_e, A_c);
@@ -32,12 +32,12 @@ fnmadds(void *frD, void *frA, void *frB, void *frC)
 
 	if ((A_c == FP_CLS_INF && C_c == FP_CLS_ZERO) ||
 	    (A_c == FP_CLS_ZERO && C_c == FP_CLS_INF))
-                ret |= EFLAG_VXIMZ;
+                FP_SET_EXCEPTION(EFLAG_VXIMZ);
 
 	FP_MUL_D(T, A, C);
 
 	if (T_s != B_s && T_c == FP_CLS_INF && B_c == FP_CLS_INF)
-		ret |= EFLAG_VXISI;
+		FP_SET_EXCEPTION(EFLAG_VXISI);
 
 	FP_ADD_D(R, T, B);
 
@@ -47,6 +47,7 @@ fnmadds(void *frD, void *frA, void *frB, void *frC)
 #ifdef DEBUG
 	printk("D: %ld %lu %lu %ld (%ld)\n", R_s, R_f1, R_f0, R_e, R_c);
 #endif
+	__FP_PACK_DS(frD, R);
 
-	return (ret | __FP_PACK_DS(frD, R));
+	return FP_CUR_EXCEPTIONS;
 }
arch/powerpc/math-emu/fnmsub.c +10 -9
index f1ca748..0d91e9e 100644
@@ -2,26 +2,26 @@
 #include <linux/errno.h>
 #include <asm/uaccess.h>
 
-#include "soft-fp.h"
-#include "double.h"
+#include <math-emu/soft-fp.h>
+#include <math-emu/double.h>
 
 int
 fnmsub(void *frD, void *frA, void *frB, void *frC)
 {
+	FP_DECL_EX;
 	FP_DECL_D(R);
 	FP_DECL_D(A);
 	FP_DECL_D(B);
 	FP_DECL_D(C);
 	FP_DECL_D(T);
-	int ret = 0;
 
 #ifdef DEBUG
 	printk("%s: %p %p %p %p\n", __FUNCTION__, frD, frA, frB, frC);
 #endif
 
-	__FP_UNPACK_D(A, frA);
-	__FP_UNPACK_D(B, frB);
-	__FP_UNPACK_D(C, frC);
+	FP_UNPACK_DP(A, frA);
+	FP_UNPACK_DP(B, frB);
+	FP_UNPACK_DP(C, frC);
 
 #ifdef DEBUG
 	printk("A: %ld %lu %lu %ld (%ld)\n", A_s, A_f1, A_f0, A_e, A_c);
@@ -31,7 +31,7 @@ fnmsub(void *frD, void *frA, void *frB, void *frC)
 
 	if ((A_c == FP_CLS_INF && C_c == FP_CLS_ZERO) ||
 	    (A_c == FP_CLS_ZERO && C_c == FP_CLS_INF))
-		ret |= EFLAG_VXIMZ;
+		FP_SET_EXCEPTION(EFLAG_VXIMZ);
 
 	FP_MUL_D(T, A, C);
 
@@ -39,7 +39,7 @@ fnmsub(void *frD, void *frA, void *frB, void *frC)
 		B_s ^= 1;
 
 	if (T_s != B_s && T_c == FP_CLS_INF && B_c == FP_CLS_INF)
-		ret |= EFLAG_VXISI;
+		FP_SET_EXCEPTION(EFLAG_VXISI);
 
 	FP_ADD_D(R, T, B);
 
@@ -49,6 +49,7 @@ fnmsub(void *frD, void *frA, void *frB, void *frC)
 #ifdef DEBUG
 	printk("D: %ld %lu %lu %ld (%ld)\n", R_s, R_f1, R_f0, R_e, R_c);
 #endif
+	FP_PACK_DP(frD, R);
 
-	return (ret | __FP_PACK_D(frD, R));
+	return FP_CUR_EXCEPTIONS;
 }
arch/powerpc/math-emu/fnmsubs.c +11 -10
index 5c9a09a..1e1e168 100644
@@ -2,27 +2,27 @@
 #include <linux/errno.h>
 #include <asm/uaccess.h>
 
-#include "soft-fp.h"
-#include "double.h"
-#include "single.h"
+#include <math-emu/soft-fp.h>
+#include <math-emu/double.h>
+#include <math-emu/single.h>
 
 int
 fnmsubs(void *frD, void *frA, void *frB, void *frC)
 {
+	FP_DECL_EX;
 	FP_DECL_D(R);
 	FP_DECL_D(A);
 	FP_DECL_D(B);
 	FP_DECL_D(C);
 	FP_DECL_D(T);
-	int ret = 0;
 
 #ifdef DEBUG
 	printk("%s: %p %p %p %p\n", __FUNCTION__, frD, frA, frB, frC);
 #endif
 
-	__FP_UNPACK_D(A, frA);
-	__FP_UNPACK_D(B, frB);
-	__FP_UNPACK_D(C, frC);
+	FP_UNPACK_DP(A, frA);
+	FP_UNPACK_DP(B, frB);
+	FP_UNPACK_DP(C, frC);
 
 #ifdef DEBUG
 	printk("A: %ld %lu %lu %ld (%ld)\n", A_s, A_f1, A_f0, A_e, A_c);
@@ -32,7 +32,7 @@ fnmsubs(void *frD, void *frA, void *frB, void *frC)
 
 	if ((A_c == FP_CLS_INF && C_c == FP_CLS_ZERO) ||
 	    (A_c == FP_CLS_ZERO && C_c == FP_CLS_INF))
-		ret |= EFLAG_VXIMZ;
+		FP_SET_EXCEPTION(EFLAG_VXIMZ);
 
 	FP_MUL_D(T, A, C);
 
@@ -40,7 +40,7 @@ fnmsubs(void *frD, void *frA, void *frB, void *frC)
 		B_s ^= 1;
 
 	if (T_s != B_s && T_c == FP_CLS_INF && B_c == FP_CLS_INF)
-		ret |= EFLAG_VXISI;
+		FP_SET_EXCEPTION(EFLAG_VXISI);
 
 	FP_ADD_D(R, T, B);
 
@@ -50,6 +50,7 @@ fnmsubs(void *frD, void *frA, void *frB, void *frC)
 #ifdef DEBUG
 	printk("D: %ld %lu %lu %ld (%ld)\n", R_s, R_f1, R_f0, R_e, R_c);
 #endif
+	__FP_PACK_DS(frD, R);
 
-	return (ret | __FP_PACK_DS(frD, R));
+	return FP_CUR_EXCEPTIONS;
 }
arch/powerpc/math-emu/frsp.c +7 -5
index d879b2a..6438823 100644
@@ -2,24 +2,26 @@
 #include <linux/errno.h>
 #include <asm/uaccess.h>
 
-#include "soft-fp.h"
-#include "double.h"
-#include "single.h"
+#include <math-emu/soft-fp.h>
+#include <math-emu/double.h>
+#include <math-emu/single.h>
 
 int
 frsp(void *frD, void *frB)
 {
+	FP_DECL_EX;
 	FP_DECL_D(B);
 
 #ifdef DEBUG
 	printk("%s: D %p, B %p\n", __FUNCTION__, frD, frB);
 #endif
 
-	__FP_UNPACK_D(B, frB);
+	FP_UNPACK_DP(B, frB);
 
 #ifdef DEBUG
 	printk("B: %ld %lu %lu %ld (%ld)\n", B_s, B_f1, B_f0, B_e, B_c);
 #endif
+	__FP_PACK_DS(frD, B);
 
-	return __FP_PACK_DS(frD, B);
+	return FP_CUR_EXCEPTIONS;
 }
arch/powerpc/math-emu/fsel.c +5 -4
index e36e6e7..6fadfb3 100644
@@ -2,19 +2,20 @@
 #include <linux/errno.h>
 #include <asm/uaccess.h>
 
-#include "soft-fp.h"
-#include "double.h"
+#include <math-emu/soft-fp.h>
+#include <math-emu/double.h>
 
 int
 fsel(u32 *frD, void *frA, u32 *frB, u32 *frC)
 {
+	FP_DECL_EX;
 	FP_DECL_D(A);
 
 #ifdef DEBUG
 	printk("%s: %p %p %p %p\n", __FUNCTION__, frD, frA, frB, frC);
 #endif
 
-	__FP_UNPACK_D(A, frA);
+	FP_UNPACK_DP(A, frA);
 
 #ifdef DEBUG
 	printk("A: %ld %lu %lu %ld (%ld)\n", A_s, A_f1, A_f0, A_e, A_c);
@@ -34,5 +35,5 @@ fsel(u32 *frD, void *frA, u32 *frB, u32 *frC)
 	printk("D: %08x.%08x\n", frD[0], frD[1]);
 #endif
 
-	return 0;
+	return FP_CUR_EXCEPTIONS;
 }
arch/powerpc/math-emu/fsqrt.c +8 -7
index 6f8319f..febd878 100644
@@ -2,36 +2,37 @@
 #include <linux/errno.h>
 #include <asm/uaccess.h>
 
-#include "soft-fp.h"
-#include "double.h"
+#include <math-emu/soft-fp.h>
+#include <math-emu/double.h>
 
 int
 fsqrt(void *frD, void *frB)
 {
+	FP_DECL_EX;
 	FP_DECL_D(B);
 	FP_DECL_D(R);
-	int ret = 0;
 
 #ifdef DEBUG
 	printk("%s: %p %p %p %p\n", __FUNCTION__, frD, frB);
 #endif
 
-	__FP_UNPACK_D(B, frB);
+	FP_UNPACK_DP(B, frB);
 
 #ifdef DEBUG
 	printk("B: %ld %lu %lu %ld (%ld)\n", B_s, B_f1, B_f0, B_e, B_c);
 #endif
 
 	if (B_s && B_c != FP_CLS_ZERO)
-		ret |= EFLAG_VXSQRT;
+		FP_SET_EXCEPTION(EFLAG_VXSQRT);
 	if (B_c == FP_CLS_NAN)
-		ret |= EFLAG_VXSNAN;
+		FP_SET_EXCEPTION(EFLAG_VXSNAN);
 
 	FP_SQRT_D(R, B);
 
 #ifdef DEBUG
 	printk("R: %ld %lu %lu %ld (%ld)\n", R_s, R_f1, R_f0, R_e, R_c);
 #endif
+	FP_PACK_DP(frD, R);
 
-	return (ret | __FP_PACK_D(frD, R));
+	return FP_CUR_EXCEPTIONS;
 }
arch/powerpc/math-emu/fsqrts.c +9 -8
index 3b2b1cf..fad4f8b 100644
@@ -2,37 +2,38 @@
 #include <linux/errno.h>
 #include <asm/uaccess.h>
 
-#include "soft-fp.h"
-#include "double.h"
-#include "single.h"
+#include <math-emu/soft-fp.h>
+#include <math-emu/double.h>
+#include <math-emu/single.h>
 
 int
 fsqrts(void *frD, void *frB)
 {
+	FP_DECL_EX;
 	FP_DECL_D(B);
 	FP_DECL_D(R);
-	int ret = 0;
 
 #ifdef DEBUG
 	printk("%s: %p %p %p %p\n", __FUNCTION__, frD, frB);
 #endif
 
-	__FP_UNPACK_D(B, frB);
+	FP_UNPACK_DP(B, frB);
 
 #ifdef DEBUG
 	printk("B: %ld %lu %lu %ld (%ld)\n", B_s, B_f1, B_f0, B_e, B_c);
 #endif
 
 	if (B_s && B_c != FP_CLS_ZERO)
-		ret |= EFLAG_VXSQRT;
+		FP_SET_EXCEPTION(EFLAG_VXSQRT);
 	if (B_c == FP_CLS_NAN)
-		ret |= EFLAG_VXSNAN;
+		FP_SET_EXCEPTION(EFLAG_VXSNAN);
 
 	FP_SQRT_D(R, B);
 
 #ifdef DEBUG
 	printk("R: %ld %lu %lu %ld (%ld)\n", R_s, R_f1, R_f0, R_e, R_c);
 #endif
+	__FP_PACK_DS(frD, R);
 
-	return (ret | __FP_PACK_DS(frD, R));
+	return FP_CUR_EXCEPTIONS;
 }
arch/powerpc/math-emu/fsub.c +8 -7
index 9566790..d973919 100644
@@ -2,23 +2,23 @@
 #include <linux/errno.h>
 #include <asm/uaccess.h>
 
-#include "soft-fp.h"
-#include "double.h"
+#include <math-emu/soft-fp.h>
+#include <math-emu/double.h>
 
 int
 fsub(void *frD, void *frA, void *frB)
 {
+	FP_DECL_EX;
 	FP_DECL_D(A);
 	FP_DECL_D(B);
 	FP_DECL_D(R);
-	int ret = 0;
 
 #ifdef DEBUG
 	printk("%s: %p %p %p\n", __FUNCTION__, frD, frA, frB);
 #endif
 
-	__FP_UNPACK_D(A, frA);
-	__FP_UNPACK_D(B, frB);
+	FP_UNPACK_DP(A, frA);
+	FP_UNPACK_DP(B, frB);
 
 #ifdef DEBUG
 	printk("A: %ld %lu %lu %ld (%ld)\n", A_s, A_f1, A_f0, A_e, A_c);
@@ -29,13 +29,14 @@ fsub(void *frD, void *frA, void *frB)
 		B_s ^= 1;
 
 	if (A_s != B_s && A_c == FP_CLS_INF && B_c == FP_CLS_INF)
-		ret |= EFLAG_VXISI;
+		FP_SET_EXCEPTION(EFLAG_VXISI);
 
 	FP_ADD_D(R, A, B);
 
 #ifdef DEBUG
 	printk("D: %ld %lu %lu %ld (%ld)\n", R_s, R_f1, R_f0, R_e, R_c);
 #endif
+	FP_PACK_DP(frD, R);
 
-	return (ret | __FP_PACK_D(frD, R));
+	return FP_CUR_EXCEPTIONS;
 }
arch/powerpc/math-emu/fsubs.c +9 -8
index 3428117..3162382 100644
@@ -2,24 +2,24 @@
 #include <linux/errno.h>
 #include <asm/uaccess.h>
 
-#include "soft-fp.h"
-#include "double.h"
-#include "single.h"
+#include <math-emu/soft-fp.h>
+#include <math-emu/double.h>
+#include <math-emu/single.h>
 
 int
 fsubs(void *frD, void *frA, void *frB)
 {
+	FP_DECL_EX;
 	FP_DECL_D(A);
 	FP_DECL_D(B);
 	FP_DECL_D(R);
-	int ret = 0;
 
 #ifdef DEBUG
 	printk("%s: %p %p %p\n", __FUNCTION__, frD, frA, frB);
 #endif
 
-	__FP_UNPACK_D(A, frA);
-	__FP_UNPACK_D(B, frB);
+	FP_UNPACK_DP(A, frA);
+	FP_UNPACK_DP(B, frB);
 
 #ifdef DEBUG
 	printk("A: %ld %lu %lu %ld (%ld)\n", A_s, A_f1, A_f0, A_e, A_c);
@@ -30,13 +30,14 @@ fsubs(void *frD, void *frA, void *frB)
 		B_s ^= 1;
 
 	if (A_s != B_s && A_c == FP_CLS_INF && B_c == FP_CLS_INF)
-		ret |= EFLAG_VXISI;
+		FP_SET_EXCEPTION(EFLAG_VXISI);
 
 	FP_ADD_D(R, A, B);
 
 #ifdef DEBUG
 	printk("D: %ld %lu %lu %ld (%ld)\n", R_s, R_f1, R_f0, R_e, R_c);
 #endif
+	__FP_PACK_DS(frD, R);
 
-	return (ret | __FP_PACK_DS(frD, R));
+	return FP_CUR_EXCEPTIONS;
 }
arch/powerpc/math-emu/lfd.c +2 -2
index 7d38101..e5ad147 100644
@@ -2,8 +2,8 @@
 #include <linux/errno.h>
 #include <asm/uaccess.h>
 
-#include "sfp-machine.h"
-#include "double.h"
+#include <asm/sfp-machine.h>
+#include <math-emu/double.h>
 
 int
 lfd(void *frD, void *ea)
arch/powerpc/math-emu/lfs.c +7 -5
index c86dee3..67d3a3e 100644
@@ -2,13 +2,14 @@
 #include <linux/errno.h>
 #include <asm/uaccess.h>
 
-#include "soft-fp.h"
-#include "double.h"
-#include "single.h"
+#include <math-emu/soft-fp.h>
+#include <math-emu/double.h>
+#include <math-emu/single.h>
 
 int
 lfs(void *frD, void *ea)
 {
+	FP_DECL_EX;
 	FP_DECL_D(R);
 	FP_DECL_S(A);
 	float f;
@@ -20,7 +21,7 @@ lfs(void *frD, void *ea)
 	if (copy_from_user(&f, ea, sizeof(float)))
 		return -EFAULT;
 
-	__FP_UNPACK_S(A, &f);
+	FP_UNPACK_SP(A, &f);
 
 #ifdef DEBUG
 	printk("A: %ld %lu %ld (%ld) [%08lx]\n", A_s, A_f, A_e, A_c,
@@ -32,6 +33,7 @@ lfs(void *frD, void *ea)
 #ifdef DEBUG
 	printk("R: %ld %lu %lu %ld (%ld)\n", R_s, R_f1, R_f0, R_e, R_c);
 #endif
+	FP_PACK_DP(frD, R);
 
-	return __FP_PACK_D(frD, R);
+	return FP_CUR_EXCEPTIONS;
 }
arch/powerpc/math-emu/math.c +2 -2
index 381306b..2f355df 100644
@@ -8,8 +8,8 @@
 #include <asm/uaccess.h>
 #include <asm/reg.h>
 
-#include "sfp-machine.h"
-#include "double.h"
+#include <asm/sfp-machine.h>
+#include <math-emu/double.h>
 
 #define FLOATFUNC(x)	extern int x(void *, void *, void *, void *)
 
arch/powerpc/math-emu/mcrfs.c +1 -1
index 106dd91..219b09f 100644
@@ -2,7 +2,7 @@
 #include <linux/errno.h>
 #include <asm/uaccess.h>
 
-#include "soft-fp.h"
+#include <math-emu/soft-fp.h>
 
 int
 mcrfs(u32 *ccr, u32 crfD, u32 crfS)
arch/powerpc/math-emu/mffs.c +1 -1
index f477c91..329ff94 100644
@@ -2,7 +2,7 @@
 #include <linux/errno.h>
 #include <asm/uaccess.h>
 
-#include "soft-fp.h"
+#include <math-emu/soft-fp.h>
 
 int
 mffs(u32 *frD)
arch/powerpc/math-emu/mtfsb0.c +1 -1
index 99bfd80..3404b2f 100644
@@ -2,7 +2,7 @@
 #include <linux/errno.h>
 #include <asm/uaccess.h>
 
-#include "soft-fp.h"
+#include <math-emu/soft-fp.h>
 
 int
 mtfsb0(int crbD)
arch/powerpc/math-emu/mtfsb1.c +1 -1
index 3d9e7ed..933b333 100644
@@ -2,7 +2,7 @@
 #include <linux/errno.h>
 #include <asm/uaccess.h>
 
-#include "soft-fp.h"
+#include <math-emu/soft-fp.h>
 
 int
 mtfsb1(int crbD)
arch/powerpc/math-emu/mtfsf.c +1 -1
index d70cf71..caeceaa 100644
@@ -2,7 +2,7 @@
 #include <linux/errno.h>
 #include <asm/uaccess.h>
 
-#include "soft-fp.h"
+#include <math-emu/soft-fp.h>
 
 int
 mtfsf(unsigned int FM, u32 *frB)
arch/powerpc/math-emu/mtfsfi.c +1 -1
index 71df854..4c9777a 100644
@@ -2,7 +2,7 @@
 #include <linux/errno.h>
 #include <asm/uaccess.h>
 
-#include "soft-fp.h"
+#include <math-emu/soft-fp.h>
 
 int
 mtfsfi(unsigned int crfD, unsigned int IMM)
arch/powerpc/math-emu/stfs.c +9 -9
index e87ca23..d392b38 100644
@@ -2,23 +2,23 @@
 #include <linux/errno.h>
 #include <asm/uaccess.h>
 
-#include "soft-fp.h"
-#include "double.h"
-#include "single.h"
+#include <math-emu/soft-fp.h>
+#include <math-emu/double.h>
+#include <math-emu/single.h>
 
 int
 stfs(void *frS, void *ea)
 {
+	FP_DECL_EX;
 	FP_DECL_D(A);
 	FP_DECL_S(R);
 	float f;
-	int err;
 
 #ifdef DEBUG
 	printk("%s: S %p, ea %p\n", __FUNCTION__, frS, ea);
 #endif
 
-	__FP_UNPACK_D(A, frS);
+	FP_UNPACK_DP(A, frS);
 
 #ifdef DEBUG
 	printk("A: %ld %lu %lu %ld (%ld)\n", A_s, A_f1, A_f0, A_e, A_c);
@@ -30,12 +30,12 @@ stfs(void *frS, void *ea)
 	printk("R: %ld %lu %ld (%ld)\n", R_s, R_f, R_e, R_c);
 #endif
 
-	err = _FP_PACK_CANONICAL(S, 1, R);
-	if (!err || !__FPU_TRAP_P(err)) {
-		__FP_PACK_RAW_1(S, &f, R);
+	FP_PACK_SP(&f,R);
+
+	if (!FP_INHIBIT_RESULTS) {
 		if (copy_to_user(ea, &f, sizeof(float)))
 			return -EFAULT;
 	}
 
-	return err;
+	return FP_CUR_EXCEPTIONS;
 }
arch/powerpc/math-emu/udivmodti4.c +1 -1
index 7e112dc..6172044 100644
@@ -1,6 +1,6 @@
 /* This has so very few changes over libgcc2's __udivmoddi4 it isn't funny.  */
 
-#include "soft-fp.h"
+#include <math-emu/soft-fp.h>
 
 #undef count_leading_zeros
 #define count_leading_zeros  __FP_CLZ
Signature · 1 line
1.5.2
author
#3 lore raw
In reply to Liu Yu

Sorry. I forgot to add the serial number. The three math-emu patches are in the same serial.

Quoted 17 lines

-----Original Message-----
From: Liu Yu=20
Sent: Wednesday, March 05, 2008 5:02 PM
To: [email protected]
Cc: Liu Yu
Subject: [PATCH] math-emu: delete PowerPC old math-emu headers =20
Use common headers as a replacement.
The Common headers are located in "include/math-emu/", they are used by multiple platforms such as s390, sparc, alpha. =20
As the common headers have more developers,
they are more popular and more stable.
=20
In fact, PowerPC old math-emu headers cannot handle float point exceptions exactly while the common headers can.
=20

#4 lore raw
In reply to Liu Yu
Quoted 9 lines · Liu Yu

Use common headers as a replacement.
The Common headers are located in "include/math-emu/", they are used by multiple platforms such as s390, sparc, alpha.

As the common headers have more developers,
they are more popular and more stable.

In fact, PowerPC old math-emu headers cannot handle float point exceptions exactly while the common headers can.

That sounds like an excellent idea. However, were you able to run some kind of test suite to verify that the emulation works properly ?

Cheers,
Ben.

author
#5 lore raw
Quoted 13 lines

=20

Quoted 2 lines · Liu Yu

Use common headers as a replacement.
The Common headers are located in "include/math-emu/", they=20

are used=20

Quoted 3 lines

by multiple platforms such as s390, sparc, alpha. =20
As the common headers have more developers, they are more=20

popular and=20

Quoted 4 lines

more stable.
=20
In fact, PowerPC old math-emu headers cannot handle float point=20 exceptions exactly while the common headers can.

Quoted 5 lines

=20
That sounds like an excellent idea. However, were you able to=20 run some kind of test suite to verify that the emulation=20 works properly ?
=20

Not yet, for I don't have the right environment. :-(

We have a patch to handle MPC85xx SPE.
The patch is not yet a part of kernel and used to adopt PowerPC math-emu headers=20
like current math-emu for PowerPC FP does.=20

When we ran TestFloat which is a famous FP test suite to test the SPE patch,
it reported numerous errors and most of them concerned wrong FP exception flags.
After we change the SPE patch to the common math-emu headers, the result of TestFloat are splendid.

So I think the same change should be done on current PowerPC FP math-emu.