1 /* Raise given exceptions.
2 Copyright (C) 1997, 1999, 2000, 2002 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Contributed by David Huggins-Daines <dhd@debian.org>
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library. If not, see
18 <http://www.gnu.org/licenses/>. */
24 /* Please see section 10,
25 page 10-5 "Delayed Trapping" in the PA-RISC 2.0 Architecture manual */
28 feraiseexcept (int excepts
)
30 /* Raise exceptions represented by EXCEPTS. But we must raise only one
31 signal at a time. It is important that if the overflow/underflow
32 exception and the divide by zero exception are given at the same
33 time, the overflow/underflow exception follows the divide by zero
36 /* We do these bits in assembly to be certain GCC doesn't optimize
37 away something important, and so we can force delayed traps to
40 /* We use "fldd 0(%%sr0,%%sp),%0" to flush the delayed exception */
42 /* First: Invalid exception. */
43 if (excepts
& FE_INVALID
)
45 /* One example of a invalid operation is 0 * Infinity. */
47 __asm__
__volatile__ (
48 " fcpy,dbl %%fr0,%%fr22\n"
49 " fmpy,dbl %0,%%fr22,%0\n"
50 " fldd 0(%%sr0,%%sp),%0"
51 : "+f" (d
) : : "%fr22" );
54 /* Second: Division by zero. */
55 if (excepts
& FE_DIVBYZERO
)
58 __asm__
__volatile__ (
59 " fcpy,dbl %%fr0,%%fr22\n"
60 " fdiv,dbl %0,%%fr22,%0\n"
61 " fldd 0(%%sr0,%%sp),%0"
62 : "+f" (d
) : : "%fr22" );
65 /* Third: Overflow. */
66 if (excepts
& FE_OVERFLOW
)
69 __asm__
__volatile__ (
70 " fadd,dbl %0,%0,%0\n"
71 " fldd 0(%%sr0,%%sp),%0"
75 /* Fourth: Underflow. */
76 if (excepts
& FE_UNDERFLOW
)
80 __asm__
__volatile__ (
81 " fdiv,dbl %0,%1,%0\n"
82 " fldd 0(%%sr0,%%sp),%0"
83 : "+f" (d
) : "f" (e
) );
87 if (excepts
& FE_INEXACT
)
91 __asm__
__volatile__ (
92 " fdiv,dbl %0,%1,%%fr22\n"
93 " fcnvfxt,dbl,sgl %%fr22,%%fr22L\n"
94 " fldd 0(%%sr0,%%sp),%%fr22"
95 : : "f" (d
), "f" (e
) : "%fr22" );
101 libm_hidden_def (feraiseexcept
)