2 * Copyright (c) 2004 David Schultz <das@FreeBSD.ORG>
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * $FreeBSD: src/lib/msun/arm/fenv.c,v 1.1.20.1 2009/04/15 03:14:26 kensmith Exp $
33 * Hopefully the system ID byte is immutable, so it's valid to use
34 * this as a default environment.
36 const fenv_t __fe_dfl_env
= { };
39 /* FIXME: These are just stubs for the moment for soft-float
40 * A new implemntation is needed for hard-float support
43 /* Clear the supported exceptions represented by EXCEPTS. */
44 int feclearexcept (int __excepts
)
46 fe_env
.__status_register
&= ~(__excepts
& FE_ALL_EXCEPT
);
50 /* Store implementation-defined representation of the exception flags
51 indicated by EXCEPTS in the object pointed to by FLAGP. */
52 int fegetexceptflag (fexcept_t
*__flagp
, int __excepts
)
54 *__flagp
= (fe_env
.__status_register
& __excepts
& FE_ALL_EXCEPT
);
58 /* Raise the supported exceptions represented by EXCEPTS. */
59 int feraiseexcept (int __excepts
)
61 if (__excepts
& (FE_UNDERFLOW
| FE_OVERFLOW
)) {
63 } else if (__excepts
) {
69 /* Set complete status for exceptions indicated by EXCEPTS according to
70 the representation in the object pointed to by FLAGP. */
71 int fesetexceptflag(const fexcept_t
*flagp
, int excepts
)
73 fe_env
.__status_register
&= ~(excepts
& FE_ALL_EXCEPT
);
74 fe_env
.__status_register
|= (*flagp
& excepts
& FE_ALL_EXCEPT
);
79 /* Determine which of subset of the exceptions specified by EXCEPTS are
81 int fetestexcept (int __excepts
)
83 return (fe_env
.__status_register
& __excepts
& FE_ALL_EXCEPT
);
86 /* Store the current floating-point environment in the object pointed
88 int fegetenv (fenv_t
*envp
)
94 /* Save the current environment in the object pointed to by ENVP, clear
95 exception flags and install a non-stop mode (if available) for all
97 int feholdexcept (fenv_t
*envp
)
104 int fegetround(void) {
108 int fesetround(int round
) {
112 /* Establish the floating-point environment represented by the object
113 pointed to by ENVP. */
114 int fesetenv(const fenv_t
*envp
)
120 /* Save current exceptions in temporary storage, install environment
121 represented by object pointed to by ENVP and raise exceptions
122 according to saved exceptions. */
123 int feupdateenv(const fenv_t
*envp
)
125 int fexcept
= fe_env
.__status_register
;
127 feraiseexcept(fexcept
);