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 */
5
6 /* Store current floating-point environment and clear exceptions.
7 Copyright (C) 1997-2013 Free Software Foundation, Inc.
8
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.
13
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.
18
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/>. */
22
23 #include <fenv.h>
24 #include <fpu_control.h>
25 #include "fenv_libc.h"
26
27 int
feholdexcept(fenv_t * envp)28 feholdexcept (fenv_t *envp)
29 {
30 #ifdef __NDS32_ABI_2FP_PLUS__
31 unsigned long int temp;
32
33 /* Store the environment. */
34 _FPU_GETCW(temp);
35 envp->__fpcsr = temp;
36
37 /* Now set all exceptions to non-stop. */
38 temp &= ~(FE_ALL_EXCEPT << ENABLE_SHIFT);
39
40 /* And clear all exception flags. */
41 temp &= ~FE_ALL_EXCEPT;
42
43 _FPU_SETCW(temp);
44
45 return 0;
46 #else
47 /* Unsupported, so fail. */
48 return 1;
49 #endif
50 }
51
52