sdk-core
v2026.11.05
PS2 SDK - core tier (build-critical EE/IOP modules)
Toggle main menu visibility
Loading...
Searching...
No Matches
fenv-fp.h
Go to the documentation of this file.
1
/*-
2
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3
*
4
* Copyright (c) 2004-2005 David Schultz <das@FreeBSD.ORG>
5
* All rights reserved.
6
*
7
* Redistribution and use in source and binary forms, with or without
8
* modification, are permitted provided that the following conditions
9
* are met:
10
* 1. Redistributions of source code must retain the above copyright
11
* notice, this list of conditions and the following disclaimer.
12
* 2. Redistributions in binary form must reproduce the above copyright
13
* notice, this list of conditions and the following disclaimer in the
14
* documentation and/or other materials provided with the distribution.
15
*
16
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26
* SUCH DAMAGE.
27
*
28
* $FreeBSD$
29
*/
30
35
__fenv_static
inline
int
36
feclearexcept(
int
excepts)
37
{
38
fexcept_t fcsr;
39
40
excepts &= FE_ALL_EXCEPT;
41
__cfc1(fcsr);
42
fcsr &= ~(excepts | (excepts << _FCSR_CAUSE_SHIFT));
43
__ctc1(fcsr);
44
45
return
(0);
46
}
47
48
__fenv_static
inline
int
49
fegetexceptflag(fexcept_t *flagp,
int
excepts)
50
{
51
fexcept_t fcsr;
52
53
excepts &= FE_ALL_EXCEPT;
54
__cfc1(fcsr);
55
*flagp = fcsr & excepts;
56
57
return
(0);
58
}
59
60
__fenv_static
inline
int
61
fesetexceptflag(
const
fexcept_t *flagp,
int
excepts)
62
{
63
fexcept_t fcsr;
64
65
excepts &= FE_ALL_EXCEPT;
66
__cfc1(fcsr);
67
fcsr &= ~excepts;
68
fcsr |= *flagp & excepts;
69
__ctc1(fcsr);
70
71
return
(0);
72
}
73
74
__fenv_static
inline
int
75
feraiseexcept(
int
excepts)
76
{
77
fexcept_t fcsr;
78
79
excepts &= FE_ALL_EXCEPT;
80
__cfc1(fcsr);
81
fcsr |= excepts | (excepts << _FCSR_CAUSE_SHIFT);
82
__ctc1(fcsr);
83
84
return
(0);
85
}
86
87
__fenv_static
inline
int
88
fetestexcept(
int
excepts)
89
{
90
fexcept_t fcsr;
91
92
excepts &= FE_ALL_EXCEPT;
93
__cfc1(fcsr);
94
95
return
(fcsr & excepts);
96
}
97
98
__fenv_static
inline
int
99
fegetround(
void
)
100
{
101
fexcept_t fcsr;
102
103
__cfc1(fcsr);
104
105
return
(fcsr & _ROUND_MASK);
106
}
107
108
__fenv_static
inline
int
109
fesetround(
int
rounding_mode)
110
{
111
fexcept_t fcsr;
112
113
if
(rounding_mode & ~_ROUND_MASK)
114
return
(-1);
115
116
__cfc1(fcsr);
117
fcsr &= ~_ROUND_MASK;
118
fcsr |= rounding_mode;
119
__ctc1(fcsr);
120
121
return
(0);
122
}
123
124
__fenv_static
inline
int
125
fegetenv(fenv_t *envp)
126
{
127
128
__cfc1(*envp);
129
130
return
(0);
131
}
132
133
__fenv_static
inline
int
134
feholdexcept(fenv_t *envp)
135
{
136
fexcept_t fcsr;
137
138
__cfc1(fcsr);
139
*envp = fcsr;
140
fcsr &= ~(FE_ALL_EXCEPT | _ENABLE_MASK);
141
__ctc1(fcsr);
142
143
return
(0);
144
}
145
146
__fenv_static
inline
int
147
fesetenv(
const
fenv_t *envp)
148
{
149
150
__ctc1(*envp);
151
152
return
(0);
153
}
154
155
__fenv_static
inline
int
156
feupdateenv(
const
fenv_t *envp)
157
{
158
fexcept_t fcsr;
159
160
__cfc1(fcsr);
161
fesetenv(envp);
162
feraiseexcept(fcsr);
163
164
return
(0);
165
}
166
#if __BSD_VISIBLE
167
168
/* We currently provide no external definitions of the functions below. */
169
170
#ifdef __mips_soft_float
171
int
feenableexcept(
int
__mask);
172
int
fedisableexcept(
int
__mask);
173
int
fegetexcept(
void
);
174
#else
175
static
inline
int
176
feenableexcept(
int
__mask)
177
{
178
fenv_t __old_fcsr, __new_fcsr;
179
180
__cfc1(__old_fcsr);
181
__new_fcsr = __old_fcsr | (__mask & FE_ALL_EXCEPT) << _ENABLE_SHIFT;
182
__ctc1(__new_fcsr);
183
184
return
((__old_fcsr >> _ENABLE_SHIFT) & FE_ALL_EXCEPT);
185
}
186
187
static
inline
int
188
fedisableexcept(
int
__mask)
189
{
190
fenv_t __old_fcsr, __new_fcsr;
191
192
__cfc1(__old_fcsr);
193
__new_fcsr = __old_fcsr & ~((__mask & FE_ALL_EXCEPT) << _ENABLE_SHIFT);
194
__ctc1(__new_fcsr);
195
196
return
((__old_fcsr >> _ENABLE_SHIFT) & FE_ALL_EXCEPT);
197
}
198
199
static
inline
int
200
fegetexcept(
void
)
201
{
202
fexcept_t fcsr;
203
204
__cfc1(fcsr);
205
206
return
((fcsr & _ENABLE_MASK) >> _ENABLE_SHIFT);
207
}
208
209
#endif
/* !__mips_soft_float */
210
211
#endif
/* __BSD_VISIBLE */
core
sysclib
src
newlib
libc
machine
mips
machine
fenv-fp.h
Generated by
1.18.0