stfs.c 784 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. stfs(void *frS, void *ea)
  10. {
  11. FP_DECL_D(A);
  12. FP_DECL_S(R);
  13. FP_DECL_EX;
  14. float f;
  15. #ifdef DEBUG
  16. printk("%s: S %p, ea %p\n", __func__, frS, ea);
  17. #endif
  18. FP_UNPACK_DP(A, frS);
  19. #ifdef DEBUG
  20. printk("A: %ld %lu %lu %ld (%ld)\n", A_s, A_f1, A_f0, A_e, A_c);
  21. #endif
  22. FP_CONV(S, D, 1, 2, R, A);
  23. #ifdef DEBUG
  24. printk("R: %ld %lu %ld (%ld)\n", R_s, R_f, R_e, R_c);
  25. #endif
  26. _FP_PACK_CANONICAL(S, 1, R);
  27. if (!FP_CUR_EXCEPTIONS || !__FPU_TRAP_P(FP_CUR_EXCEPTIONS)) {
  28. _FP_PACK_RAW_1_P(S, &f, R);
  29. if (copy_to_user(ea, &f, sizeof(float)))
  30. return -EFAULT;
  31. }
  32. return FP_CUR_EXCEPTIONS;
  33. }