fsqrt.c 708 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #include <linux/types.h>
  2. #include <linux/errno.h>
  3. #include <asm/uaccess.h>
  4. #include <asm/sfp-machine.h>
  5. #include <math-emu/soft-fp.h>
  6. #include <math-emu/double.h>
  7. int
  8. fsqrt(void *frD, void *frB)
  9. {
  10. FP_DECL_D(B);
  11. FP_DECL_D(R);
  12. FP_DECL_EX;
  13. #ifdef DEBUG
  14. printk("%s: %p %p %p %p\n", __func__, frD, frB);
  15. #endif
  16. FP_UNPACK_DP(B, frB);
  17. #ifdef DEBUG
  18. printk("B: %ld %lu %lu %ld (%ld)\n", B_s, B_f1, B_f0, B_e, B_c);
  19. #endif
  20. if (B_s && B_c != FP_CLS_ZERO)
  21. FP_SET_EXCEPTION(EFLAG_VXSQRT);
  22. if (B_c == FP_CLS_NAN)
  23. FP_SET_EXCEPTION(EFLAG_VXSNAN);
  24. FP_SQRT_D(R, B);
  25. #ifdef DEBUG
  26. printk("R: %ld %lu %lu %ld (%ld)\n", R_s, R_f1, R_f0, R_e, R_c);
  27. #endif
  28. __FP_PACK_D(frD, R);
  29. return FP_CUR_EXCEPTIONS;
  30. }