]>
git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/ia64/fpu/fraiseexcpt.c
02b0c4ead1b234f73c0d04e33418e6c71e0520e5
1 /* Raise given exceptions.
2 Copyright (C) 1997-2024 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
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.
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.
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/>. */
26 __feraiseexcept (int excepts
)
31 /* Raise exceptions represented by EXPECTS. But we must raise only
32 one signal at a time. It is important the if the overflow/underflow
33 exception and the inexact exception are given at the same time,
34 the overflow/underflow exception precedes the inexact exception. */
36 /* We do these bits in assembly to be certain GCC doesn't optimize
37 away something important. */
39 /* First: invalid exception. */
40 if (FE_INVALID
& excepts
)
42 /* One example of an invalid operation is 0 * Infinity. */
44 __asm__
__volatile__ ("frcpa.s0 %0,p1=f0,f0" : "=f" (tmp
) : : "p1" );
47 /* Next: division by zero. */
48 if (FE_DIVBYZERO
& excepts
)
49 __asm__
__volatile__ ("frcpa.s0 %0,p1=f1,f0" : "=f" (tmp
) : : "p1" );
52 if (FE_OVERFLOW
& excepts
)
56 __asm__
__volatile__ ("fadd.d.s0 %0=%1,%1" : "=f" (dummy
) : "0" (dummy
));
59 /* Next: underflow. */
60 if (FE_UNDERFLOW
& excepts
)
64 __asm__
__volatile__ ("fnma.d.s0 %0=%1,%1,f0" : "=f" (tmp
) : "f" (dummy
));
68 if (FE_INEXACT
& excepts
)
71 __asm__
__volatile__ ("fsub.d.s0 %0=%1,f1" : "=f" (dummy
) : "0" (dummy
));
77 libm_hidden_def (__feraiseexcept
)
78 weak_alias (__feraiseexcept
, feraiseexcept
)
79 libm_hidden_weak (feraiseexcept
)