1 /* Copyright (C) 1997-2000, 2006, 2011, 2012 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 <http://www.gnu.org/licenses/>. */
19 * ISO C99: 7.3 Complex arithmetic <complex.h>
27 /* Get general and ISO C99 specific information. */
28 #include <bits/mathdef.h>
32 /* We might need to add support for more compilers here. But since ISO
33 C99 is out hopefully all maintained compilers will soon provide the data
34 types `float complex' and `double complex'. */
35 #if __GNUC_PREREQ (2, 7) && !__GNUC_PREREQ (2, 97)
36 # define _Complex __complex__
39 #define complex _Complex
41 /* Narrowest imaginary unit. This depends on the floating-point
43 XXX This probably has to go into a gcc related file. */
44 #define _Complex_I (__extension__ 1.0iF)
46 /* Another more descriptive name is `I'.
47 XXX Once we have the imaginary support switch this to _Imaginary_I. */
51 #if defined __USE_ISOC11 && __GNUC_PREREQ (4, 7)
52 /* Macros to expand into expression of specified complex type. */
53 # define CMPLX(x, y) __builtin_complex ((double) (x), (double) (y))
54 # define CMPLXF(x, y) __builtin_complex ((float) (x), (float) (y))
55 # ifndef __NO_LONG_DOUBLE_MATH
56 # define CMPLXL(x, y) __builtin_complex ((long double) (x), (long double) (y))
60 /* The file <bits/cmathcalls.h> contains the prototypes for all the
61 actual math functions. These macros are used for those prototypes,
62 so we can easily declare each function as both `name' and `__name',
63 and can declare the float versions `namef' and `__namef'. */
65 #define __MATHCALL(function, args) \
66 __MATHDECL (_Mdouble_complex_,function, args)
67 #define __MATHDECL(type, function, args) \
68 __MATHDECL_1(type, function, args); \
69 __MATHDECL_1(type, __CONCAT(__,function), args)
70 #define __MATHDECL_1(type, function, args) \
71 extern type __MATH_PRECNAME(function) args __THROW
73 #define _Mdouble_ double
74 #define __MATH_PRECNAME(name) name
75 #include <bits/cmathcalls.h>
77 #undef __MATH_PRECNAME
79 /* Now the float versions. */
81 # define _Mfloat_ float
83 #define _Mdouble_ _Mfloat_
84 #define __MATH_PRECNAME(name) name##f
85 #include <bits/cmathcalls.h>
87 #undef __MATH_PRECNAME
89 /* And the long double versions. It is non-critical to define them
90 here unconditionally since `long double' is required in ISO C99. */
91 #if !(defined __NO_LONG_DOUBLE_MATH && defined _LIBC) \
92 || defined __LDBL_COMPAT
95 # define __MATHDECL_1(type, function, args) \
96 extern type __REDIRECT_NTH(__MATH_PRECNAME(function), args, function)
99 # ifndef _Mlong_double_
100 # define _Mlong_double_ long double
102 # define _Mdouble_ _Mlong_double_
103 # define __MATH_PRECNAME(name) name##l
104 # include <bits/cmathcalls.h>
107 #undef __MATH_PRECNAME
114 #endif /* complex.h */