xref: /haiku/src/system/libroot/posix/glibc/math/complex.h (revision 1a76488fc88584bf66b9751d7fb9b6527ac20d87)
1 /* Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
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
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.
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
12    Lesser General Public License for more details.
13 
14    You should have received a copy of the GNU Lesser General Public
15    License along with the GNU C Library; if not, write to the Free
16    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
17    02111-1307 USA.  */
18 
19 /*
20  *	ISO C99:  7.3 Complex arithmetic	<complex.h>
21  */
22 
23 #ifndef _COMPLEX_H
24 #define _COMPLEX_H	1
25 
26 #include <features.h>
27 
28 __BEGIN_DECLS
29 
30 #if __GNUC__ >= 7
31 #define __isinfl(value) __builtin_isinfl(value)
32 #define __isnan(value) __builtin_isnan(value)
33 #define __isnanf(value) __builtin_isnanf(value)
34 #define __isnanl(value) __builtin_isnanl(value)
35 #define __isinf(value) __builtin_isinf(value)
36 #define __isinff(value) __builtin_isinff(value)
37 #endif
38 
39 /* We might need to add support for more compilers here.  But since ISO
40    C99 is out hopefully all maintained compilers will soon provide the data
41    types `float complex' and `double complex'.  */
42 #if __GNUC_PREREQ (2, 7) && !__GNUC_PREREQ (2, 97)
43 # define _Complex __complex__
44 #endif
45 
46 #define complex		_Complex
47 
48 /* Narrowest imaginary unit.  This depends on the floating-point
49    evaluation method.
50    XXX This probably has to go into a gcc related file.  */
51 #define _Complex_I	(__extension__ 1.0iF)
52 
53 /* Another more descriptive name is `I'.
54    XXX Once we have the imaginary support switch this to _Imaginary_I.  */
55 #undef I
56 #define I _Complex_I
57 
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',
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) \
69   extern type __MATH_PRECNAME(function) args __THROW
70 
71 #define _Mdouble_ 		double
72 #define __MATH_PRECNAME(name)	name
73 #include <bits/cmathcalls.h>
74 #undef	_Mdouble_
75 #undef	__MATH_PRECNAME
76 
77 /* Now the float versions.  */
78 #ifndef _Mfloat_
79 # define _Mfloat_		float
80 #endif
81 #define _Mdouble_ 		_Mfloat_
82 #ifdef __STDC__
83 # define __MATH_PRECNAME(name)	name##f
84 #else
85 # define __MATH_PRECNAME(name)	name/**/f
86 #endif
87 #include <bits/cmathcalls.h>
88 #undef	_Mdouble_
89 #undef	__MATH_PRECNAME
90 
91 /* And the long double versions.  It is non-critical to define them
92    here unconditionally since `long double' is required in ISO C99.  */
93 #if (__STDC__ - 0 || __GNUC__ - 0) && !defined __NO_LONG_DOUBLE_MATH
94 # ifndef _Mlong_double_
95 #  define _Mlong_double_	long double
96 # endif
97 # define _Mdouble_ 		_Mlong_double_
98 # ifdef __STDC__
99 #  define __MATH_PRECNAME(name)	name##l
100 # else
101 #  define __MATH_PRECNAME(name)	name/**/l
102 # endif
103 # include <bits/cmathcalls.h>
104 #endif
105 #undef	_Mdouble_
106 #undef	__MATH_PRECNAME
107 #undef	__MATHDECL_1
108 #undef	__MATHDECL
109 #undef	__MATHCALL
110 
111 __END_DECLS
112 
113 #endif /* complex.h */
114