1 /* Declarations for SVID math error handling compatibility.
2    Copyright (C) 1991-2022 Free Software Foundation, Inc.
3    This file is part of the GNU C Library.
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, see
17    <https://www.gnu.org/licenses/>.  */
18 
19 #ifndef	_MATH_SVID_COMPAT_H
20 #define	_MATH_SVID_COMPAT_H	1
21 
22 /* Support for various different standard error handling behaviors.  */
23 typedef enum
24 {
25   _IEEE_ = -1,	/* According to IEEE 754/IEEE 854.  */
26   _SVID_,	/* According to System V, release 4.  */
27   _XOPEN_,	/* Nowadays also Unix98.  */
28   _POSIX_,
29   _ISOC_	/* Actually this is ISO C99.  */
30 } _LIB_VERSION_TYPE;
31 
32 /* This variable can be changed at run-time to any of the values above to
33    affect floating point error handling behavior (it may also be necessary
34    to change the hardware FPU exception settings).  */
35 extern _LIB_VERSION_TYPE _LIB_VERSION;
36 
37 /* In SVID error handling, `matherr' is called with this description
38    of the exceptional condition.  */
39 struct exception
40   {
41     int type;
42     char *name;
43     double arg1;
44     double arg2;
45     double retval;
46   };
47 
48 extern int matherr (struct exception *__exc);
49 extern int __matherr (struct exception *__exc);
50 
51 #define X_TLOSS	1.41484755040568800000e+16
52 #define AS_FLOAT_CONSTANT_1(x) x##f
53 #define AS_FLOAT_CONSTANT(x) AS_FLOAT_CONSTANT_1(x)
54 
55 /* Types of exceptions in the `type' field.  */
56 #define DOMAIN		1
57 #define SING		2
58 #define OVERFLOW	3
59 #define UNDERFLOW	4
60 #define TLOSS		5
61 #define PLOSS		6
62 
63 /* SVID mode specifies returning this large value instead of infinity.  */
64 #define HUGE		3.40282347e+38F
65 
66 /* The above definitions may be used in testcases.  The following code
67    is only used in the implementation.  */
68 
69 #ifdef _LIBC
70 /* fdlibm kernel function */
71 extern double __kernel_standard (double, double, int);
72 extern float __kernel_standard_f (float, float, int);
73 extern long double __kernel_standard_l (long double, long double, int);
74 
75 # include <shlib-compat.h>
76 # define LIBM_SVID_COMPAT SHLIB_COMPAT (libm, GLIBC_2_0, GLIBC_2_27)
77 # if LIBM_SVID_COMPAT
78 compat_symbol_reference (libm, matherr, matherr, GLIBC_2_0);
79 compat_symbol_reference (libm, _LIB_VERSION, _LIB_VERSION, GLIBC_2_0);
80 # else
81 /* Except when building compat code, optimize out references to
82    _LIB_VERSION and matherr.  */
83 #  define _LIB_VERSION _POSIX_
84 #  define matherr(EXC) ((void) (EXC), 0)
85 # endif
86 #endif
87 
88 #endif /* math-svid-compat.h.  */
89