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
;
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
)
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
;
77 /* Determine which of subset of the exceptions specified by EXCEPTS are
79 int fetestexcept (int __excepts
)
81 return (fe_env
.__status_register
& __excepts
);
84 /* Store the current floating-point environment in the object pointed
86 int fegetenv (fenv_t
*envp
)
92 /* Save the current environment in the object pointed to by ENVP, clear
93 exception flags and install a non-stop mode (if available) for all
95 int feholdexcept (fenv_t
*envp
)
102 int fegetround(void) {
106 int fesetround(int round
) {
110 /* Establish the floating-point environment represented by the object
111 pointed to by ENVP. */
112 int fesetenv(const fenv_t
*envp
)
118 /* Save current exceptions in temporary storage, install environment
119 represented by object pointed to by ENVP and raise exceptions
120 according to saved exceptions. */
121 int feupdateenv(const fenv_t
*envp
)
123 int fexcept
= fe_env
.__status_register
;
125 feraiseexcept(fexcept
);