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 /* Install given floating-point environment and raise exceptions.
7    Copyright (C) 1997-2013 Free Software Foundation, Inc.
8    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
9 
10    The GNU C Library is free software; you can redistribute it and/or
11    modify it under the terms of the GNU Lesser General Public
12    License as published by the Free Software Foundation; either
13    version 2.1 of the License, or (at your option) any later version.
14 
15    The GNU C Library is distributed in the hope that it will be useful,
16    but WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18    Lesser General Public License for more details.
19 
20    You should have received a copy of the GNU Lesser General Public
21    License along with the GNU C Library.  If not, see
22    <http://www.gnu.org/licenses/>.  */
23 
24 #include <fenv.h>
25 #include <fpu_control.h>
26 
27 int
feupdateenv(const fenv_t * envp)28 feupdateenv (const fenv_t *envp)
29 {
30 #ifdef __NDS32_ABI_2FP_PLUS__
31 	unsigned int temp;
32 
33 	/* Get the current exception state.  */
34 	_FPU_GETCW (temp);
35 
36 	/* Install new environment.  */
37 	fesetenv (envp);
38 
39 	/* Raise the saved exceptions.  */
40 	feraiseexcept (temp & FE_ALL_EXCEPT);
41 
42 	/* Success.  */
43 	return 0;
44 #else
45 	/* Unsupported, so fail.  */
46 	return 1;
47 #endif
48 }
49