]> git.ipfire.org Git - thirdparty/glibc.git/blame - math/complex.h
Improve __ieee754_exp() performance by greater than 5x on sparc/x86.
[thirdparty/glibc.git] / math / complex.h
CommitLineData
bfff8b1b 1/* Copyright (C) 1997-2017 Free Software Foundation, Inc.
4cca6b86
UD
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
41bdb6e2
AJ
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.
4cca6b86
UD
8
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
41bdb6e2 12 Lesser General Public License for more details.
4cca6b86 13
41bdb6e2 14 You should have received a copy of the GNU Lesser General Public
59ba27a6
PE
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
4cca6b86
UD
17
18/*
d1646309 19 * ISO C99: 7.3 Complex arithmetic <complex.h>
4cca6b86
UD
20 */
21
22#ifndef _COMPLEX_H
23#define _COMPLEX_H 1
5107cf1d 24
fcee5905
PM
25#define __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION
26#include <bits/libc-header-start.h>
993b3242 27
63ae7b63 28/* Get general and ISO C99 specific information. */
1792d4db
UD
29#include <bits/mathdef.h>
30
fcee5905
PM
31/* Gather machine-dependent _FloatN type support. */
32#include <bits/floatn.h>
33
993b3242 34__BEGIN_DECLS
4cca6b86 35
63ae7b63
UD
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
4cca6b86 38 types `float complex' and `double complex'. */
b4a555d6 39#if __GNUC_PREREQ (2, 7) && !__GNUC_PREREQ (2, 97)
1792d4db 40# define _Complex __complex__
4cca6b86
UD
41#endif
42
5985c772 43#define complex _Complex
4cca6b86
UD
44
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. */
5985c772 48#define _Complex_I (__extension__ 1.0iF)
4cca6b86 49
fe0ec73e
UD
50/* Another more descriptive name is `I'.
51 XXX Once we have the imaginary support switch this to _Imaginary_I. */
4cca6b86 52#undef I
fe0ec73e 53#define I _Complex_I
4cca6b86 54
ac097f5c
UD
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))
2ee094ff 59# define CMPLXL(x, y) __builtin_complex ((long double) (x), (long double) (y))
ac097f5c
UD
60#endif
61
43e66283
JM
62#if __HAVE_FLOAT16 && __GLIBC_USE (IEC_60559_TYPES_EXT)
63# define CMPLXF16(x, y) __builtin_complex ((_Float16) (x), (_Float16) (y))
64#endif
65
66#if __HAVE_FLOAT32 && __GLIBC_USE (IEC_60559_TYPES_EXT)
67# define CMPLXF32(x, y) __builtin_complex ((_Float32) (x), (_Float32) (y))
68#endif
69
70#if __HAVE_FLOAT64 && __GLIBC_USE (IEC_60559_TYPES_EXT)
71# define CMPLXF64(x, y) __builtin_complex ((_Float64) (x), (_Float64) (y))
72#endif
73
fcee5905
PM
74#if __HAVE_FLOAT128 && __GLIBC_USE (IEC_60559_TYPES_EXT)
75# define CMPLXF128(x, y) __builtin_complex ((_Float128) (x), (_Float128) (y))
76#endif
77
43e66283
JM
78#if __HAVE_FLOAT32X && __GLIBC_USE (IEC_60559_TYPES_EXT)
79# define CMPLXF32X(x, y) __builtin_complex ((_Float32x) (x), (_Float32x) (y))
80#endif
81
82#if __HAVE_FLOAT64X && __GLIBC_USE (IEC_60559_TYPES_EXT)
83# define CMPLXF64X(x, y) __builtin_complex ((_Float64x) (x), (_Float64x) (y))
84#endif
85
86#if __HAVE_FLOAT128X && __GLIBC_USE (IEC_60559_TYPES_EXT)
87# define CMPLXF128X(x, y) \
88 __builtin_complex ((_Float128x) (x), (_Float128x) (y))
89#endif
90
5107cf1d
UD
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',
4cca6b86
UD
94 and can declare the float versions `namef' and `__namef'. */
95
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(type, function, args) \
c1422e5b 102 extern type __MATH_PRECNAME(function) args __THROW
4cca6b86
UD
103
104#define _Mdouble_ double
105#define __MATH_PRECNAME(name) name
5107cf1d 106#include <bits/cmathcalls.h>
4cca6b86
UD
107#undef _Mdouble_
108#undef __MATH_PRECNAME
109
110/* Now the float versions. */
eda162dd 111#define _Mdouble_ float
7071ad79 112#define __MATH_PRECNAME(name) name##f
5107cf1d 113#include <bits/cmathcalls.h>
4cca6b86
UD
114#undef _Mdouble_
115#undef __MATH_PRECNAME
116
117/* And the long double versions. It is non-critical to define them
63ae7b63 118 here unconditionally since `long double' is required in ISO C99. */
7071ad79
JM
119#if !(defined __NO_LONG_DOUBLE_MATH && defined _LIBC) \
120 || defined __LDBL_COMPAT
c6251f03
RM
121# ifdef __LDBL_COMPAT
122# undef __MATHDECL_1
123# define __MATHDECL_1(type, function, args) \
4442d58f 124 extern type __REDIRECT_NTH(__MATH_PRECNAME(function), args, function)
c6251f03
RM
125# endif
126
eda162dd 127# define _Mdouble_ long double
7071ad79 128# define __MATH_PRECNAME(name) name##l
1792d4db 129# include <bits/cmathcalls.h>
4cca6b86 130#endif
4cca6b86
UD
131#undef _Mdouble_
132#undef __MATH_PRECNAME
2f1b212e 133
260fbd0a
JM
134#if (__HAVE_DISTINCT_FLOAT16 || (__HAVE_FLOAT16 && !defined _LIBC)) \
135 && __GLIBC_USE (IEC_60559_TYPES_EXT)
136# undef _Mdouble_complex_
137# define _Mdouble_complex_ __CFLOAT16
138# define _Mdouble_ _Float16
139# define __MATH_PRECNAME(name) name##f16
140# include <bits/cmathcalls.h>
141# undef _Mdouble_
142# undef __MATH_PRECNAME
143# undef _Mdouble_complex_
144#endif
145
146#if (__HAVE_DISTINCT_FLOAT32 || (__HAVE_FLOAT32 && !defined _LIBC)) \
147 && __GLIBC_USE (IEC_60559_TYPES_EXT)
148# undef _Mdouble_complex_
149# define _Mdouble_complex_ __CFLOAT32
150# define _Mdouble_ _Float32
151# define __MATH_PRECNAME(name) name##f32
152# include <bits/cmathcalls.h>
153# undef _Mdouble_
154# undef __MATH_PRECNAME
155# undef _Mdouble_complex_
156#endif
157
158#if (__HAVE_DISTINCT_FLOAT64 || (__HAVE_FLOAT64 && !defined _LIBC)) \
159 && __GLIBC_USE (IEC_60559_TYPES_EXT)
160# undef _Mdouble_complex_
161# define _Mdouble_complex_ __CFLOAT64
162# define _Mdouble_ _Float64
163# define __MATH_PRECNAME(name) name##f64
164# include <bits/cmathcalls.h>
165# undef _Mdouble_
166# undef __MATH_PRECNAME
167# undef _Mdouble_complex_
168#endif
169
2f1b212e
JM
170#if (__HAVE_DISTINCT_FLOAT128 || (__HAVE_FLOAT128 && !defined _LIBC)) \
171 && __GLIBC_USE (IEC_60559_TYPES_EXT)
172# undef _Mdouble_complex_
173# define _Mdouble_complex_ __CFLOAT128
174# define _Mdouble_ _Float128
175# define __MATH_PRECNAME(name) name##f128
176# include <bits/cmathcalls.h>
177# undef _Mdouble_
178# undef __MATH_PRECNAME
179# undef _Mdouble_complex_
180#endif
181
260fbd0a
JM
182#if (__HAVE_DISTINCT_FLOAT32X || (__HAVE_FLOAT32X && !defined _LIBC)) \
183 && __GLIBC_USE (IEC_60559_TYPES_EXT)
184# undef _Mdouble_complex_
185# define _Mdouble_complex_ __CFLOAT32X
186# define _Mdouble_ _Float32x
187# define __MATH_PRECNAME(name) name##f32x
188# include <bits/cmathcalls.h>
189# undef _Mdouble_
190# undef __MATH_PRECNAME
191# undef _Mdouble_complex_
192#endif
193
194#if (__HAVE_DISTINCT_FLOAT64X || (__HAVE_FLOAT64X && !defined _LIBC)) \
195 && __GLIBC_USE (IEC_60559_TYPES_EXT)
196# undef _Mdouble_complex_
197# define _Mdouble_complex_ __CFLOAT64X
198# define _Mdouble_ _Float64x
199# define __MATH_PRECNAME(name) name##f64x
200# include <bits/cmathcalls.h>
201# undef _Mdouble_
202# undef __MATH_PRECNAME
203# undef _Mdouble_complex_
204#endif
205
206#if (__HAVE_DISTINCT_FLOAT128X || (__HAVE_FLOAT128X && !defined _LIBC)) \
207 && __GLIBC_USE (IEC_60559_TYPES_EXT)
208# undef _Mdouble_complex_
209# define _Mdouble_complex_ __CFLOAT128X
210# define _Mdouble_ _Float128x
211# define __MATH_PRECNAME(name) name##f128x
212# include <bits/cmathcalls.h>
213# undef _Mdouble_
214# undef __MATH_PRECNAME
215# undef _Mdouble_complex_
216#endif
217
4cca6b86
UD
218#undef __MATHDECL_1
219#undef __MATHDECL
220#undef __MATHCALL
221
993b3242
UD
222__END_DECLS
223
4cca6b86 224#endif /* complex.h */