fix regression from a745c4bfc8a9b5db4e48387170da0dc1d39e3abe
[uclibc-ng.git] / libm / nds32 / fesetenv.c
blob4682d3c8e0aca27722a70d9c5413d03846f0fdd9
1 /*
2 * Copyright (C) 2016-2017 Andes Technology, Inc.
3 * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
4 */
6 /* Install given floating-point environment.
7 Copyright (C) 2004-2013 Free Software Foundation, Inc.
9 The GNU C Library is free software; you can redistribute it and/or
10 modify it under the terms of the GNU Lesser General Public
11 License as published by the Free Software Foundation; either
12 version 2.1 of the License, or (at your option) any later version.
14 The GNU C Library is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Lesser General Public License for more details.
19 You should have received a copy of the GNU Lesser General Public
20 License along with the GNU C Library. If not, see
21 <http://www.gnu.org/licenses/>. */
23 #include <fenv.h>
24 #include <fpu_control.h>
26 int
27 fesetenv (const fenv_t *envp)
29 #ifdef __NDS32_ABI_2FP_PLUS__
30 unsigned int temp;
32 _FPU_GETCW (temp);
33 temp &= _FPU_RESERVED;
35 if (envp == FE_DFL_ENV)
36 temp |= _FPU_DEFAULT;
37 else if (envp == FE_NOMASK_ENV)
38 temp |= _FPU_IEEE;
39 else
40 temp |= envp->__fpcsr & ~_FPU_RESERVED;
42 _FPU_SETCW (temp);
44 /* Success. */
45 return 0;
46 #else
48 /* Unsupported, so fail. */
49 return 1;
50 #endif