Update to LGPL v2.1.
[jlayton/glibc.git] / sysdeps / s390 / fpu / bits / fenv.h
1 /* Copyright (C) 2000 Free Software Foundation, Inc.
2    This file is part of the GNU C Library.
3    Contributed by Denis Joseph Barrow (djbarrow@de.ibm.com).
4
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.
9
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.
14
15    You should have received a copy of the GNU Lesser General Public
16    License along with the GNU C Library; if not, write to the Free
17    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18    02111-1307 USA.  */
19
20 #ifndef _FENV_H
21 # error "Never use <bits/fenv.h> directly; include <fenv.h> instead."
22 #endif
23
24 /* Define bits representing the exception.  We use the bit positions
25    of the appropriate bits in the FPU control word.  */
26 enum
27   {
28     FE_INVALID = 0x80,
29 #define FE_INVALID      FE_INVALID
30     FE_DIVBYZERO = 0x40,
31 #define FE_DIVBYZERO    FE_DIVBYZERO
32     FE_OVERFLOW = 0x20,
33 #define FE_OVERFLOW     FE_OVERFLOW
34     FE_UNDERFLOW = 0x10,
35 #define FE_UNDERFLOW    FE_UNDERFLOW
36     FE_INEXACT = 0x08
37 #define FE_INEXACT      FE_INEXACT
38   };
39 /* We dont use the y bit of the DXC in the floating point control register
40    as glibc has no FE encoding for fe inexact incremented
41    or fe inexact truncated.
42    We currently  use the flag bits in the fpc
43    as these are sticky for feholdenv & feupdatenv as it is defined
44    in the HP Manpages.  */
45
46
47 #define FE_ALL_EXCEPT \
48         (FE_INEXACT | FE_DIVBYZERO | FE_UNDERFLOW | FE_OVERFLOW | FE_INVALID)
49
50 enum
51   {
52     FE_TONEAREST = 0,
53 #define FE_TONEAREST    FE_TONEAREST
54     FE_DOWNWARD = 0x3,
55 #define FE_DOWNWARD     FE_DOWNWARD
56     FE_UPWARD = 0x2,
57 #define FE_UPWARD       FE_UPWARD
58     FE_TOWARDZERO = 0x1
59 #define FE_TOWARDZERO   FE_TOWARDZERO
60   };
61
62
63 /* Type representing exception flags.  */
64 typedef unsigned int fexcept_t; /* size of fpc */
65
66
67 /* Type representing floating-point environment.  This function corresponds
68    to the layout of the block written by the `fstenv'.  */
69 typedef struct
70 {
71   fexcept_t fpc;
72   void *ieee_instruction_pointer;
73   /* failing instruction for ieee exceptions */
74 } fenv_t;
75
76 /* If the default argument is used we use this value.  */
77 #define FE_DFL_ENV      ((__const fenv_t *) -1)
78
79 #ifdef __USE_GNU
80 /* Floating-point environment where none of the exceptions are masked.  */
81 # define FE_NOMASK_ENV  ((__const fenv_t *) -2)
82 #endif