]> git.ipfire.org Git - thirdparty/glibc.git/blame - math/complex.h
Update copyright dates with scripts/update-copyrights.
[thirdparty/glibc.git] / math / complex.h
CommitLineData
b168057a 1/* Copyright (C) 1997-2015 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
993b3242
UD
25#include <features.h>
26
63ae7b63 27/* Get general and ISO C99 specific information. */
1792d4db
UD
28#include <bits/mathdef.h>
29
993b3242 30__BEGIN_DECLS
4cca6b86 31
63ae7b63
UD
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
4cca6b86 34 types `float complex' and `double complex'. */
b4a555d6 35#if __GNUC_PREREQ (2, 7) && !__GNUC_PREREQ (2, 97)
1792d4db 36# define _Complex __complex__
4cca6b86
UD
37#endif
38
5985c772 39#define complex _Complex
4cca6b86
UD
40
41/* Narrowest imaginary unit. This depends on the floating-point
42 evaluation method.
43 XXX This probably has to go into a gcc related file. */
5985c772 44#define _Complex_I (__extension__ 1.0iF)
4cca6b86 45
fe0ec73e
UD
46/* Another more descriptive name is `I'.
47 XXX Once we have the imaginary support switch this to _Imaginary_I. */
4cca6b86 48#undef I
fe0ec73e 49#define I _Complex_I
4cca6b86 50
ac097f5c
UD
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))
2ee094ff 55# define CMPLXL(x, y) __builtin_complex ((long double) (x), (long double) (y))
ac097f5c
UD
56#endif
57
5107cf1d
UD
58/* The file <bits/cmathcalls.h> contains the prototypes for all the
59 actual math functions. These macros are used for those prototypes,
60 so we can easily declare each function as both `name' and `__name',
4cca6b86
UD
61 and can declare the float versions `namef' and `__namef'. */
62
63#define __MATHCALL(function, args) \
64 __MATHDECL (_Mdouble_complex_,function, args)
65#define __MATHDECL(type, function, args) \
66 __MATHDECL_1(type, function, args); \
67 __MATHDECL_1(type, __CONCAT(__,function), args)
68#define __MATHDECL_1(type, function, args) \
c1422e5b 69 extern type __MATH_PRECNAME(function) args __THROW
4cca6b86
UD
70
71#define _Mdouble_ double
72#define __MATH_PRECNAME(name) name
5107cf1d 73#include <bits/cmathcalls.h>
4cca6b86
UD
74#undef _Mdouble_
75#undef __MATH_PRECNAME
76
77/* Now the float versions. */
78#ifndef _Mfloat_
1792d4db 79# define _Mfloat_ float
4cca6b86
UD
80#endif
81#define _Mdouble_ _Mfloat_
7071ad79 82#define __MATH_PRECNAME(name) name##f
5107cf1d 83#include <bits/cmathcalls.h>
4cca6b86
UD
84#undef _Mdouble_
85#undef __MATH_PRECNAME
86
87/* And the long double versions. It is non-critical to define them
63ae7b63 88 here unconditionally since `long double' is required in ISO C99. */
7071ad79
JM
89#if !(defined __NO_LONG_DOUBLE_MATH && defined _LIBC) \
90 || defined __LDBL_COMPAT
c6251f03
RM
91# ifdef __LDBL_COMPAT
92# undef __MATHDECL_1
93# define __MATHDECL_1(type, function, args) \
4442d58f 94 extern type __REDIRECT_NTH(__MATH_PRECNAME(function), args, function)
c6251f03
RM
95# endif
96
1792d4db
UD
97# ifndef _Mlong_double_
98# define _Mlong_double_ long double
99# endif
100# define _Mdouble_ _Mlong_double_
7071ad79 101# define __MATH_PRECNAME(name) name##l
1792d4db 102# include <bits/cmathcalls.h>
4cca6b86 103#endif
4cca6b86
UD
104#undef _Mdouble_
105#undef __MATH_PRECNAME
106#undef __MATHDECL_1
107#undef __MATHDECL
108#undef __MATHCALL
109
993b3242
UD
110__END_DECLS
111
4cca6b86 112#endif /* complex.h */