fdiv.c 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #include <linux/types.h>
  2. #include <linux/errno.h>
  3. #include <asm/uaccess.h>
  4. #include "soft-fp.h"
  5. #include "double.h"
  6. int
  7. fdiv(void *frD, void *frA, void *frB)
  8. {
  9. FP_DECL_D(A);
  10. FP_DECL_D(B);
  11. FP_DECL_D(R);
  12. int ret = 0;
  13. #ifdef DEBUG
  14. printk("%s: %p %p %p\n", __FUNCTION__, frD, frA, frB);
  15. #endif
  16. __FP_UNPACK_D(A, frA);
  17. __FP_UNPACK_D(B, frB);
  18. #ifdef DEBUG
  19. printk("A: %ld %lu %lu %ld (%ld)\n", A_s, A_f1, A_f0, A_e, A_c);
  20. printk("B: %ld %lu %lu %ld (%ld)\n", B_s, B_f1, B_f0, B_e, B_c);
  21. #endif
  22. if (A_c == FP_CLS_ZERO && B_c == FP_CLS_ZERO) {
  23. ret |= EFLAG_VXZDZ;
  24. #ifdef DEBUG
  25. printk("%s: FPSCR_VXZDZ raised\n", __FUNCTION__);
  26. #endif
  27. }
  28. if (A_c == FP_CLS_INF && B_c == FP_CLS_INF) {
  29. ret |= EFLAG_VXIDI;
  30. #ifdef DEBUG
  31. printk("%s: FPSCR_VXIDI raised\n", __FUNCTION__);
  32. #endif
  33. }
  34. if (B_c == FP_CLS_ZERO && A_c != FP_CLS_ZERO) {
  35. ret |= EFLAG_DIVZERO;
  36. if (__FPU_TRAP_P(EFLAG_DIVZERO))
  37. return ret;
  38. }
  39. FP_DIV_D(R, A, B);
  40. #ifdef DEBUG
  41. printk("D: %ld %lu %lu %ld (%ld)\n", R_s, R_f1, R_f0, R_e, R_c);
  42. #endif
  43. return (ret | __FP_PACK_D(frD, R));
  44. }