lfs.c 792 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. #include <math-emu/single.h>
  8. int
  9. lfs(void *frD, void *ea)
  10. {
  11. FP_DECL_D(R);
  12. FP_DECL_S(A);
  13. FP_DECL_EX;
  14. float f;
  15. #ifdef DEBUG
  16. printk("%s: D %p, ea %p\n", __func__, frD, ea);
  17. #endif
  18. if (copy_from_user(&f, ea, sizeof(float)))
  19. return -EFAULT;
  20. FP_UNPACK_S(A, f);
  21. #ifdef DEBUG
  22. printk("A: %ld %lu %ld (%ld) [%08lx]\n", A_s, A_f, A_e, A_c,
  23. *(unsigned long *)&f);
  24. #endif
  25. FP_CONV(D, S, 2, 1, R, A);
  26. #ifdef DEBUG
  27. printk("R: %ld %lu %lu %ld (%ld)\n", R_s, R_f1, R_f0, R_e, R_c);
  28. #endif
  29. if (R_c == FP_CLS_NAN) {
  30. R_e = _FP_EXPMAX_D;
  31. _FP_PACK_RAW_2_P(D, frD, R);
  32. } else {
  33. __FP_PACK_D(frD, R);
  34. }
  35. return 0;
  36. }