0001
0002 #include <linux/types.h>
0003 #include <linux/errno.h>
0004 #include <linux/uaccess.h>
0005
0006 #include <asm/sfp-machine.h>
0007 #include <math-emu/soft-fp.h>
0008 #include <math-emu/double.h>
0009
0010 int
0011 fnmadd(void *frD, void *frA, void *frB, void *frC)
0012 {
0013 FP_DECL_D(R);
0014 FP_DECL_D(A);
0015 FP_DECL_D(B);
0016 FP_DECL_D(C);
0017 FP_DECL_D(T);
0018 FP_DECL_EX;
0019
0020 #ifdef DEBUG
0021 printk("%s: %p %p %p %p\n", __func__, frD, frA, frB, frC);
0022 #endif
0023
0024 FP_UNPACK_DP(A, frA);
0025 FP_UNPACK_DP(B, frB);
0026 FP_UNPACK_DP(C, frC);
0027
0028 #ifdef DEBUG
0029 printk("A: %ld %lu %lu %ld (%ld)\n", A_s, A_f1, A_f0, A_e, A_c);
0030 printk("B: %ld %lu %lu %ld (%ld)\n", B_s, B_f1, B_f0, B_e, B_c);
0031 printk("C: %ld %lu %lu %ld (%ld)\n", C_s, C_f1, C_f0, C_e, C_c);
0032 #endif
0033
0034 if ((A_c == FP_CLS_INF && C_c == FP_CLS_ZERO) ||
0035 (A_c == FP_CLS_ZERO && C_c == FP_CLS_INF))
0036 FP_SET_EXCEPTION(EFLAG_VXIMZ);
0037
0038 FP_MUL_D(T, A, C);
0039
0040 if (T_s != B_s && T_c == FP_CLS_INF && B_c == FP_CLS_INF)
0041 FP_SET_EXCEPTION(EFLAG_VXISI);
0042
0043 FP_ADD_D(R, T, B);
0044
0045 if (R_c != FP_CLS_NAN)
0046 R_s ^= 1;
0047
0048 #ifdef DEBUG
0049 printk("D: %ld %lu %lu %ld (%ld)\n", R_s, R_f1, R_f0, R_e, R_c);
0050 #endif
0051
0052 __FP_PACK_D(frD, R);
0053
0054 return FP_CUR_EXCEPTIONS;
0055 }