]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/s390/fpu/fraiseexcpt.c
Update copyright notices with scripts/update-copyrights
[thirdparty/glibc.git] / sysdeps / s390 / fpu / fraiseexcpt.c
CommitLineData
528be9fe 1/* Raise given exceptions.
d4697bc9 2 Copyright (C) 2000-2014 Free Software Foundation, Inc.
528be9fe
AJ
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).
6
7 The GNU C Library is free software; you can redistribute it and/or
41bdb6e2
AJ
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.
528be9fe
AJ
11
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
41bdb6e2 15 Lesser General Public License for more details.
528be9fe 16
41bdb6e2 17 You should have received a copy of the GNU Lesser General Public
59ba27a6
PE
18 License along with the GNU C Library; if not, see
19 <http://www.gnu.org/licenses/>. */
528be9fe
AJ
20
21#include <fenv_libc.h>
7e118246 22#include <float.h>
528be9fe
AJ
23#include <math.h>
24
25
26static __inline__ void
27fexceptdiv (float d, float e)
28{
29 __asm__ __volatile__ ("debr %0,%1" : : "f" (d), "f" (e) );
30}
31
32static __inline__ void
33fexceptadd (float d, float e)
34{
35 __asm__ __volatile__ ("aebr %0,%1" : : "f" (d), "f" (e) );
36}
37
38
39int
40feraiseexcept (int excepts)
41{
42 /* Raise exceptions represented by EXPECTS. But we must raise only
43 one signal at a time. It is important that if the overflow/underflow
44 exception and the inexact exception are given at the same time,
45 the overflow/underflow exception follows the inexact exception. */
46
47 /* First: invalid exception. */
48 if (FE_INVALID & excepts)
49 fexceptdiv (0.0, 0.0);
50
51 /* Next: division by zero. */
52 if (FE_DIVBYZERO & excepts)
53 fexceptdiv (1.0, 0.0);
54
55 /* Next: overflow. */
56 if (FE_OVERFLOW & excepts)
57 /* I don't think we can do the same trick as intel so we will have
58 to live with inexact coming also. */
59 fexceptadd (FLT_MAX, 1.0e32);
60
61 /* Next: underflow. */
62 if (FE_UNDERFLOW & excepts)
63 fexceptdiv (FLT_MIN, 3.0);
64
65 /* Last: inexact. */
66 if (FE_INEXACT & excepts)
67 fexceptdiv (2.0, 3.0);
68
69 /* Success. */
70 return 0;
71}
76f2646f 72libm_hidden_def (feraiseexcept)