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 fsqrt(void *frD, void *frB)
0012 {
0013 FP_DECL_D(B);
0014 FP_DECL_D(R);
0015 FP_DECL_EX;
0016
0017 #ifdef DEBUG
0018 printk("%s: %p %p %p %p\n", __func__, frD, frB);
0019 #endif
0020
0021 FP_UNPACK_DP(B, frB);
0022
0023 #ifdef DEBUG
0024 printk("B: %ld %lu %lu %ld (%ld)\n", B_s, B_f1, B_f0, B_e, B_c);
0025 #endif
0026
0027 if (B_s && B_c != FP_CLS_ZERO)
0028 FP_SET_EXCEPTION(EFLAG_VXSQRT);
0029 if (B_c == FP_CLS_NAN)
0030 FP_SET_EXCEPTION(EFLAG_VXSNAN);
0031
0032 FP_SQRT_D(R, B);
0033
0034 #ifdef DEBUG
0035 printk("R: %ld %lu %lu %ld (%ld)\n", R_s, R_f1, R_f0, R_e, R_c);
0036 #endif
0037
0038 __FP_PACK_D(frD, R);
0039
0040 return FP_CUR_EXCEPTIONS;
0041 }