Undefine redirections after long double definition on __LDBL_COMPAT [BZ #23294]
[glibc.git] / math / complex.h
blob42f3fd7517b401513b7608c5850e6c91c328f95c
1 /* Copyright (C) 1997-2020 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <https://www.gnu.org/licenses/>. */
19 * ISO C99: 7.3 Complex arithmetic <complex.h>
22 #ifndef _COMPLEX_H
23 #define _COMPLEX_H 1
25 #define __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION
26 #include <bits/libc-header-start.h>
28 /* Get general and ISO C99 specific information. */
29 #include <bits/mathdef.h>
31 /* Gather machine-dependent _FloatN type support. */
32 #include <bits/floatn.h>
34 __BEGIN_DECLS
36 /* We might need to add support for more compilers here. But since ISO
37 C99 is out hopefully all maintained compilers will soon provide the data
38 types `float complex' and `double complex'. */
39 #if __GNUC_PREREQ (2, 7) && !__GNUC_PREREQ (2, 97)
40 # define _Complex __complex__
41 #endif
43 #define complex _Complex
45 /* Narrowest imaginary unit. This depends on the floating-point
46 evaluation method.
47 XXX This probably has to go into a gcc related file. */
48 #define _Complex_I (__extension__ 1.0iF)
50 /* Another more descriptive name is `I'.
51 XXX Once we have the imaginary support switch this to _Imaginary_I. */
52 #undef I
53 #define I _Complex_I
55 #if defined __USE_ISOC11 && __GNUC_PREREQ (4, 7)
56 /* Macros to expand into expression of specified complex type. */
57 # define CMPLX(x, y) __builtin_complex ((double) (x), (double) (y))
58 # define CMPLXF(x, y) __builtin_complex ((float) (x), (float) (y))
59 # define CMPLXL(x, y) __builtin_complex ((long double) (x), (long double) (y))
60 #endif
62 #if __HAVE_FLOAT16 && __GLIBC_USE (IEC_60559_TYPES_EXT)
63 # define CMPLXF16(x, y) __builtin_complex ((_Float16) (x), (_Float16) (y))
64 #endif
66 #if __HAVE_FLOAT32 && __GLIBC_USE (IEC_60559_TYPES_EXT)
67 # define CMPLXF32(x, y) __builtin_complex ((_Float32) (x), (_Float32) (y))
68 #endif
70 #if __HAVE_FLOAT64 && __GLIBC_USE (IEC_60559_TYPES_EXT)
71 # define CMPLXF64(x, y) __builtin_complex ((_Float64) (x), (_Float64) (y))
72 #endif
74 #if __HAVE_FLOAT128 && __GLIBC_USE (IEC_60559_TYPES_EXT)
75 # define CMPLXF128(x, y) __builtin_complex ((_Float128) (x), (_Float128) (y))
76 #endif
78 #if __HAVE_FLOAT32X && __GLIBC_USE (IEC_60559_TYPES_EXT)
79 # define CMPLXF32X(x, y) __builtin_complex ((_Float32x) (x), (_Float32x) (y))
80 #endif
82 #if __HAVE_FLOAT64X && __GLIBC_USE (IEC_60559_TYPES_EXT)
83 # define CMPLXF64X(x, y) __builtin_complex ((_Float64x) (x), (_Float64x) (y))
84 #endif
86 #if __HAVE_FLOAT128X && __GLIBC_USE (IEC_60559_TYPES_EXT)
87 # define CMPLXF128X(x, y) \
88 __builtin_complex ((_Float128x) (x), (_Float128x) (y))
89 #endif
91 /* The file <bits/cmathcalls.h> contains the prototypes for all the
92 actual math functions. These macros are used for those prototypes,
93 so we can easily declare each function as both `name' and `__name',
94 and can declare the float versions `namef' and `__namef'. */
96 #define __MATHCALL(function, args) \
97 __MATHDECL (_Mdouble_complex_,function, args)
98 #define __MATHDECL(type, function, args) \
99 __MATHDECL_1(type, function, args); \
100 __MATHDECL_1(type, __CONCAT(__,function), args)
101 #define __MATHDECL_1_IMPL(type, function, args) \
102 extern type __MATH_PRECNAME(function) args __THROW
103 #define __MATHDECL_1(type, function, args) \
104 __MATHDECL_1_IMPL(type, function, args)
106 #define _Mdouble_ double
107 #define __MATH_PRECNAME(name) name
108 #include <bits/cmathcalls.h>
109 #undef _Mdouble_
110 #undef __MATH_PRECNAME
112 /* Now the float versions. */
113 #define _Mdouble_ float
114 #define __MATH_PRECNAME(name) name##f
115 #include <bits/cmathcalls.h>
116 #undef _Mdouble_
117 #undef __MATH_PRECNAME
119 /* And the long double versions. It is non-critical to define them
120 here unconditionally since `long double' is required in ISO C99. */
121 #if !(defined __NO_LONG_DOUBLE_MATH && defined _LIBC) \
122 || defined __LDBL_COMPAT
123 # ifdef __LDBL_COMPAT
124 # undef __MATHDECL_1
125 # define __MATHDECL_1(type, function, args) \
126 extern type __REDIRECT_NTH(__MATH_PRECNAME(function), args, function)
127 # endif
129 # define _Mdouble_ long double
130 # define __MATH_PRECNAME(name) name##l
131 # include <bits/cmathcalls.h>
132 # if defined __LDBL_COMPAT
133 # undef __MATHDECL_1
134 # define __MATHDECL_1(type, function, args) \
135 __MATHDECL_1_IMPL(type, function, args)
136 # endif
137 #endif
138 #undef _Mdouble_
139 #undef __MATH_PRECNAME
141 #if (__HAVE_DISTINCT_FLOAT16 || (__HAVE_FLOAT16 && !defined _LIBC)) \
142 && __GLIBC_USE (IEC_60559_TYPES_EXT)
143 # undef _Mdouble_complex_
144 # define _Mdouble_complex_ __CFLOAT16
145 # define _Mdouble_ _Float16
146 # define __MATH_PRECNAME(name) name##f16
147 # include <bits/cmathcalls.h>
148 # undef _Mdouble_
149 # undef __MATH_PRECNAME
150 # undef _Mdouble_complex_
151 #endif
153 #if (__HAVE_DISTINCT_FLOAT32 || (__HAVE_FLOAT32 && !defined _LIBC)) \
154 && __GLIBC_USE (IEC_60559_TYPES_EXT)
155 # undef _Mdouble_complex_
156 # define _Mdouble_complex_ __CFLOAT32
157 # define _Mdouble_ _Float32
158 # define __MATH_PRECNAME(name) name##f32
159 # include <bits/cmathcalls.h>
160 # undef _Mdouble_
161 # undef __MATH_PRECNAME
162 # undef _Mdouble_complex_
163 #endif
165 #if (__HAVE_DISTINCT_FLOAT64 || (__HAVE_FLOAT64 && !defined _LIBC)) \
166 && __GLIBC_USE (IEC_60559_TYPES_EXT)
167 # undef _Mdouble_complex_
168 # define _Mdouble_complex_ __CFLOAT64
169 # define _Mdouble_ _Float64
170 # define __MATH_PRECNAME(name) name##f64
171 # include <bits/cmathcalls.h>
172 # undef _Mdouble_
173 # undef __MATH_PRECNAME
174 # undef _Mdouble_complex_
175 #endif
177 #if (__HAVE_DISTINCT_FLOAT128 || (__HAVE_FLOAT128 && !defined _LIBC)) \
178 && __GLIBC_USE (IEC_60559_TYPES_EXT)
179 # undef _Mdouble_complex_
180 # define _Mdouble_complex_ __CFLOAT128
181 # define _Mdouble_ _Float128
182 # define __MATH_PRECNAME(name) name##f128
183 # include <bits/cmathcalls.h>
184 # undef _Mdouble_
185 # undef __MATH_PRECNAME
186 # undef _Mdouble_complex_
187 #endif
189 #if (__HAVE_DISTINCT_FLOAT32X || (__HAVE_FLOAT32X && !defined _LIBC)) \
190 && __GLIBC_USE (IEC_60559_TYPES_EXT)
191 # undef _Mdouble_complex_
192 # define _Mdouble_complex_ __CFLOAT32X
193 # define _Mdouble_ _Float32x
194 # define __MATH_PRECNAME(name) name##f32x
195 # include <bits/cmathcalls.h>
196 # undef _Mdouble_
197 # undef __MATH_PRECNAME
198 # undef _Mdouble_complex_
199 #endif
201 #if (__HAVE_DISTINCT_FLOAT64X || (__HAVE_FLOAT64X && !defined _LIBC)) \
202 && __GLIBC_USE (IEC_60559_TYPES_EXT)
203 # undef _Mdouble_complex_
204 # define _Mdouble_complex_ __CFLOAT64X
205 # define _Mdouble_ _Float64x
206 # define __MATH_PRECNAME(name) name##f64x
207 # include <bits/cmathcalls.h>
208 # undef _Mdouble_
209 # undef __MATH_PRECNAME
210 # undef _Mdouble_complex_
211 #endif
213 #if (__HAVE_DISTINCT_FLOAT128X || (__HAVE_FLOAT128X && !defined _LIBC)) \
214 && __GLIBC_USE (IEC_60559_TYPES_EXT)
215 # undef _Mdouble_complex_
216 # define _Mdouble_complex_ __CFLOAT128X
217 # define _Mdouble_ _Float128x
218 # define __MATH_PRECNAME(name) name##f128x
219 # include <bits/cmathcalls.h>
220 # undef _Mdouble_
221 # undef __MATH_PRECNAME
222 # undef _Mdouble_complex_
223 #endif
225 #undef __MATHDECL_1_IMPL
226 #undef __MATHDECL_1
227 #undef __MATHDECL
228 #undef __MATHCALL
230 __END_DECLS
232 #endif /* complex.h */