1/* Set floating-point environment exception handling.
2 Copyright (C) 2000-2024 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
18
19#include <fenv_libc.h>
20#include <math.h>
21#include <fpu_control.h>
22
23int
24fesetexceptflag (const fexcept_t *flagp, int excepts)
25{
26 fexcept_t fpc, fpc_new;
27
28 /* Get the current environment. We have to do this since we cannot
29 separately set the status word. */
30 _FPU_GETCW (fpc);
31
32 /* Clear the current exception bits. */
33 fpc_new = fpc & ~((excepts & FE_ALL_EXCEPT) << FPC_FLAGS_SHIFT);
34 if ((fpc & FPC_NOT_FPU_EXCEPTION) == 0)
35 /* Bits 6, 7 of dxc-byte are zero,
36 thus bits 0-5 of dxc-byte correspond to the flag-bits.
37 Clear given exceptions in dxc-field. */
38 fpc_new &= ~((excepts & FE_ALL_EXCEPT) << FPC_DXC_SHIFT);
39
40 /* Set exceptions from flagp in flags-field. */
41 fpc_new |= (*flagp & excepts & FE_ALL_EXCEPT) << FPC_FLAGS_SHIFT;
42
43 /* Store the new status word (along with the rest of the environment.
44 Possibly new exceptions are set but they won't get executed. */
45 _FPU_SETCW (fpc_new);
46
47 /* Success. */
48 return 0;
49}
50

source code of glibc/sysdeps/s390/fpu/fsetexcptflg.c