GNU Linux-libre 5.10.217-gnu1
[releases.git] / arch / nds32 / math-emu / fdivd.c
1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (C) 2005-2018 Andes Technology Corporation
3
4 #include <linux/uaccess.h>
5 #include <asm/sfp-machine.h>
6 #include <math-emu/soft-fp.h>
7 #include <math-emu/double.h>
8
9 void fdivd(void *ft, void *fa, void *fb)
10 {
11         FP_DECL_D(A);
12         FP_DECL_D(B);
13         FP_DECL_D(R);
14         FP_DECL_EX;
15
16         FP_UNPACK_DP(A, fa);
17         FP_UNPACK_DP(B, fb);
18
19         if (B_c == FP_CLS_ZERO && A_c != FP_CLS_ZERO)
20                 FP_SET_EXCEPTION(FP_EX_DIVZERO);
21
22         FP_DIV_D(R, A, B);
23
24         FP_PACK_DP(ft, R);
25
26         __FPU_FPCSR |= FP_CUR_EXCEPTIONS;
27 }