S390: Ifunc resolver macro for vector instructions.
[glibc.git] / sysdeps / m68k / coldfire / fpu / fraiseexcpt.c
blobb96b09042c7fe448d23b2df12555deb0c187fc4f
1 /* Raise given exceptions.
2 Copyright (C) 2006-2015 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 <http://www.gnu.org/licenses/>. */
19 #include <fenv.h>
20 #include <float.h>
21 #include <math.h>
23 int
24 __feraiseexcept (int excepts)
26 /* Raise exceptions represented by EXCEPTS. But we must raise only one
27 signal at a time. It is important that if the overflow/underflow
28 exception and the divide by zero exception are given at the same
29 time, the overflow/underflow exception follows the divide by zero
30 exception.
32 The Coldfire FPU allows an exception to be raised by asserting
33 the associated EXC bit and then executing an arbitrary arithmetic
34 instruction. fmove.l is classified as an arithmetic instruction
35 and suffices for this purpose.
37 We therefore raise an exception by setting both the EXC and AEXC
38 bit associated with the exception (the former being 6 bits to the
39 left of the latter) and then loading the longword at (%sp) into an
40 FP register. */
42 inline void
43 raise_one_exception (int mask)
45 if (excepts & mask)
47 int fpsr;
48 double unused;
50 asm volatile ("fmove%.l %/fpsr,%0" : "=d" (fpsr));
51 fpsr |= (mask << 6) | mask;
52 asm volatile ("fmove%.l %0,%/fpsr" :: "d" (fpsr));
53 asm volatile ("fmove%.l (%%sp),%0" : "=f" (unused));
57 raise_one_exception (FE_INVALID);
58 raise_one_exception (FE_DIVBYZERO);
59 raise_one_exception (FE_OVERFLOW);
60 raise_one_exception (FE_UNDERFLOW);
61 raise_one_exception (FE_INEXACT);
63 /* Success. */
64 return 0;
66 libm_hidden_def (__feraiseexcept)
67 weak_alias (__feraiseexcept, feraiseexcept)
68 libm_hidden_weak (feraiseexcept)