xref: /kernel/linux/linux-5.10/arch/nds32/math-emu/fs2siz.c (revision 8c2ecf20)
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /kernel/linux/linux-5.10/arch/nds32/math-emu/
18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0
28c2ecf20Sopenharmony_ci// Copyright (C) 2005-2019 Andes Technology Corporation
38c2ecf20Sopenharmony_ci#include <linux/uaccess.h>
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ci#include <asm/sfp-machine.h>
68c2ecf20Sopenharmony_ci#include <math-emu/soft-fp.h>
78c2ecf20Sopenharmony_ci#include <math-emu/single.h>
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_civoid fs2si_z(void *ft, void *fa)
108c2ecf20Sopenharmony_ci{
118c2ecf20Sopenharmony_ci	int r;
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci	FP_DECL_S(A);
148c2ecf20Sopenharmony_ci	FP_DECL_EX;
158c2ecf20Sopenharmony_ci
168c2ecf20Sopenharmony_ci	FP_UNPACK_SP(A, fa);
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ci	if (A_c == FP_CLS_INF) {
198c2ecf20Sopenharmony_ci		*(int *)ft = (A_s == 0) ? 0x7fffffff : 0x80000000;
208c2ecf20Sopenharmony_ci		__FPU_FPCSR |= FP_EX_INVALID;
218c2ecf20Sopenharmony_ci	} else if (A_c == FP_CLS_NAN) {
228c2ecf20Sopenharmony_ci		*(int *)ft = 0xffffffff;
238c2ecf20Sopenharmony_ci		__FPU_FPCSR |= FP_EX_INVALID;
248c2ecf20Sopenharmony_ci	} else {
258c2ecf20Sopenharmony_ci		FP_TO_INT_S(r, A, 32, 1);
268c2ecf20Sopenharmony_ci		__FPU_FPCSR |= FP_CUR_EXCEPTIONS;
278c2ecf20Sopenharmony_ci		*(int *)ft = r;
288c2ecf20Sopenharmony_ci	}
298c2ecf20Sopenharmony_ci}
30

Indexes created Thu Nov 07 10:32:03 CST 2024