Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
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 #include <math-emu/single.h>
0010 
0011 int
0012 fdivs(void *frD, void *frA, void *frB)
0013 {
0014     FP_DECL_D(A);
0015     FP_DECL_D(B);
0016     FP_DECL_D(R);
0017     FP_DECL_EX;
0018 
0019 #ifdef DEBUG
0020     printk("%s: %p %p %p\n", __func__, frD, frA, frB);
0021 #endif
0022 
0023     FP_UNPACK_DP(A, frA);
0024     FP_UNPACK_DP(B, frB);
0025 
0026 #ifdef DEBUG
0027     printk("A: %ld %lu %lu %ld (%ld)\n", A_s, A_f1, A_f0, A_e, A_c);
0028     printk("B: %ld %lu %lu %ld (%ld)\n", B_s, B_f1, B_f0, B_e, B_c);
0029 #endif
0030 
0031     if (A_c == FP_CLS_ZERO && B_c == FP_CLS_ZERO) {
0032         FP_SET_EXCEPTION(EFLAG_VXZDZ);
0033 #ifdef DEBUG
0034         printk("%s: FPSCR_VXZDZ raised\n", __func__);
0035 #endif
0036     }
0037     if (A_c == FP_CLS_INF && B_c == FP_CLS_INF) {
0038         FP_SET_EXCEPTION(EFLAG_VXIDI);
0039 #ifdef DEBUG
0040         printk("%s: FPSCR_VXIDI raised\n", __func__);
0041 #endif
0042     }
0043 
0044     if (B_c == FP_CLS_ZERO && A_c != FP_CLS_ZERO) {
0045         FP_SET_EXCEPTION(EFLAG_DIVZERO);
0046         if (__FPU_TRAP_P(EFLAG_DIVZERO))
0047             return FP_CUR_EXCEPTIONS;
0048     }
0049 
0050     FP_DIV_D(R, A, B);
0051 
0052 #ifdef DEBUG
0053     printk("D: %ld %lu %lu %ld (%ld)\n", R_s, R_f1, R_f0, R_e, R_c);
0054 #endif
0055 
0056     __FP_PACK_DS(frD, R);
0057 
0058     return FP_CUR_EXCEPTIONS;
0059 }