1 /* Functions for saving the floating-point exception status flags.
2 Copyright (C) 1997-2024 Free Software Foundation, Inc.
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 /* Based on glibc/math/fetestexceptflag.c
18 together with glibc/sysdeps/<cpu>/{fpu_control.h,fenv_private.h,fenv_libc.h}. */
25 #if (defined __x86_64__ || defined _M_X64) || (defined __i386 || defined _M_IX86)
28 fetestexceptflag (fexcept_t
const *saved_flags
, int exceptions
)
30 unsigned int flags
= (unsigned int) *saved_flags
;
31 return flags
& FE_ALL_EXCEPT
& exceptions
;
34 #elif defined __aarch64__ /* arm64 */
37 fetestexceptflag (fexcept_t
const *saved_flags
, int exceptions
)
39 unsigned long flags
= (unsigned long) *saved_flags
;
40 return flags
& FE_ALL_EXCEPT
& exceptions
;
46 fetestexceptflag (fexcept_t
const *saved_flags
, int exceptions
)
48 unsigned int flags
= (unsigned int) *saved_flags
;
49 return flags
& FE_ALL_EXCEPT
& exceptions
;
55 fetestexceptflag (fexcept_t
const *saved_flags
, int exceptions
)
57 unsigned long flags
= (unsigned long) *saved_flags
;
58 return flags
& FE_ALL_EXCEPT
& exceptions
;
64 fetestexceptflag (fexcept_t
const *saved_flags
, int exceptions
)
66 unsigned int flags
= (unsigned int) *saved_flags
;
67 return flags
& FE_ALL_EXCEPT
& exceptions
;
70 #elif defined __ia64__
73 fetestexceptflag (fexcept_t
const *saved_flags
, int exceptions
)
75 unsigned long flags
= (unsigned long) *saved_flags
;
76 return flags
& FE_ALL_EXCEPT
& exceptions
;
79 #elif defined __m68k__
82 fetestexceptflag (fexcept_t
const *saved_flags
, int exceptions
)
84 unsigned int flags
= (unsigned int) *saved_flags
;
85 return flags
& FE_ALL_EXCEPT
& exceptions
;
88 #elif defined __mips__
91 fetestexceptflag (fexcept_t
const *saved_flags
, int exceptions
)
93 unsigned int flags
= (unsigned int) *saved_flags
;
94 return flags
& FE_ALL_EXCEPT
& exceptions
;
97 #elif defined __loongarch__
100 fetestexceptflag (fexcept_t
const *saved_flags
, int exceptions
)
102 unsigned int flags
= (unsigned int) *saved_flags
;
103 return flags
& FE_ALL_EXCEPT
& exceptions
;
106 #elif defined __powerpc__
109 fetestexceptflag (fexcept_t
const *saved_flags
, int exceptions
)
111 unsigned int flags
= (unsigned int) *saved_flags
;
112 return flags
& FE_ALL_EXCEPT
& exceptions
;
115 #elif defined __riscv
118 fetestexceptflag (fexcept_t
const *saved_flags
, int exceptions
)
120 unsigned int flags
= (unsigned int) *saved_flags
;
121 return flags
& FE_ALL_EXCEPT
& exceptions
;
124 #elif defined __s390__ || defined __s390x__
127 fetestexceptflag (fexcept_t
const *saved_flags
, int exceptions
)
129 unsigned int flags
= (unsigned int) *saved_flags
;
130 return flags
& FE_ALL_EXCEPT
& exceptions
;
136 fetestexceptflag (fexcept_t
const *saved_flags
, int exceptions
)
138 unsigned int flags
= (unsigned int) *saved_flags
;
139 return flags
& FE_ALL_EXCEPT
& exceptions
;
142 #elif defined __sparc
145 fetestexceptflag (fexcept_t
const *saved_flags
, int exceptions
)
147 unsigned long flags
= (unsigned long) *saved_flags
;
148 return flags
& FE_ALL_EXCEPT
& exceptions
;
153 # if defined __GNUC__ || defined __clang__
154 # warning "Unknown CPU / architecture. Please report your platform and compiler to <bug-gnulib@gnu.org>."
156 # define NEED_FALLBACK 1
162 /* A dummy fallback. */
165 fetestexceptflag (fexcept_t
const *saved_flags
, int exceptions
)