WIP FPC-III support
[linux/fpc-iii.git] / arch / nds32 / math-emu / fd2si.c
blobfae3e16a0a10317925613ca6fe5704dce7228889
1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (C) 2005-2019 Andes Technology Corporation
3 #include <linux/uaccess.h>
5 #include <asm/sfp-machine.h>
6 #include <math-emu/soft-fp.h>
7 #include <math-emu/double.h>
9 void fd2si(void *ft, void *fa)
11 int r;
13 FP_DECL_D(A);
14 FP_DECL_EX;
16 FP_UNPACK_DP(A, fa);
18 if (A_c == FP_CLS_INF) {
19 *(int *)ft = (A_s == 0) ? 0x7fffffff : 0x80000000;
20 __FPU_FPCSR |= FP_EX_INVALID;
21 } else if (A_c == FP_CLS_NAN) {
22 *(int *)ft = 0xffffffff;
23 __FPU_FPCSR |= FP_EX_INVALID;
24 } else {
25 FP_TO_INT_ROUND_D(r, A, 32, 1);
26 __FPU_FPCSR |= FP_CUR_EXCEPTIONS;
27 *(int *)ft = r;