1 /* Raise given exceptions.
2 Copyright (C) 2000, 2002 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Contributed by Denis Joseph Barrow (djbarrow@de.ibm.com) and
5 Martin Schwidefsky (schwidefsky@de.ibm.com).
7 The GNU C Library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
12 The GNU C Library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
17 You should have received a copy of the GNU Lesser General Public
18 License along with the GNU C Library; if not, write to the Free
19 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
22 #include <fenv_libc.h>
27 static __inline__
void
28 fexceptdiv (float d
, float e
)
30 __asm__
__volatile__ ("debr %0,%1" : : "f" (d
), "f" (e
) );
33 static __inline__
void
34 fexceptadd (float d
, float e
)
36 __asm__
__volatile__ ("aebr %0,%1" : : "f" (d
), "f" (e
) );
41 feraiseexcept (int excepts
)
43 /* Raise exceptions represented by EXPECTS. But we must raise only
44 one signal at a time. It is important that if the overflow/underflow
45 exception and the inexact exception are given at the same time,
46 the overflow/underflow exception follows the inexact exception. */
48 /* First: invalid exception. */
49 if (FE_INVALID
& excepts
)
50 fexceptdiv (0.0, 0.0);
52 /* Next: division by zero. */
53 if (FE_DIVBYZERO
& excepts
)
54 fexceptdiv (1.0, 0.0);
57 if (FE_OVERFLOW
& excepts
)
58 /* I don't think we can do the same trick as intel so we will have
59 to live with inexact coming also. */
60 fexceptadd (FLT_MAX
, 1.0e32
);
62 /* Next: underflow. */
63 if (FE_UNDERFLOW
& excepts
)
64 fexceptdiv (FLT_MIN
, 3.0);
67 if (FE_INEXACT
& excepts
)
68 fexceptdiv (2.0, 3.0);
73 libm_hidden_def (feraiseexcept
)