1 | /* Copyright (C) 1997-2018 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, see |

16 | <http://www.gnu.org/licenses/>. */ |

17 | |

18 | /* |

19 | * ISO C99: 7.3 Complex arithmetic <complex.h> |

20 | */ |

21 | |

22 | #ifndef _COMPLEX_H |

23 | #define _COMPLEX_H 1 |

24 | |

25 | #define __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION |

26 | #include <bits/libc-header-start.h> |

27 | |

28 | /* Get general and ISO C99 specific information. */ |

29 | #include <bits/mathdef.h> |

30 | |

31 | /* Gather machine-dependent _FloatN type support. */ |

32 | #include <bits/floatn.h> |

33 | |

34 | __BEGIN_DECLS |

35 | |

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 |

42 | |

43 | #define complex _Complex |

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. */ |

48 | #define _Complex_I (__extension__ 1.0iF) |

49 | |

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 |

54 | |

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 |

61 | |

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 | |

74 | #if __HAVE_FLOAT128 && __GLIBC_USE (IEC_60559_TYPES_EXT) |

75 | # define CMPLXF128(x, y) __builtin_complex ((_Float128) (x), (_Float128) (y)) |

76 | #endif |

77 | |

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 | |

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'. */ |

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) \ |

102 | extern type __MATH_PRECNAME(function) args __THROW |

103 | |

104 | #define _Mdouble_ double |

105 | #define __MATH_PRECNAME(name) name |

106 | #include <bits/cmathcalls.h> |

107 | #undef _Mdouble_ |

108 | #undef __MATH_PRECNAME |

109 | |

110 | /* Now the float versions. */ |

111 | #define _Mdouble_ float |

112 | #define __MATH_PRECNAME(name) name##f |

113 | #include <bits/cmathcalls.h> |

114 | #undef _Mdouble_ |

115 | #undef __MATH_PRECNAME |

116 | |

117 | /* And the long double versions. It is non-critical to define them |

118 | here unconditionally since `long double' is required in ISO C99. */ |

119 | #if !(defined __NO_LONG_DOUBLE_MATH && defined _LIBC) \ |

120 | || defined __LDBL_COMPAT |

121 | # ifdef __LDBL_COMPAT |

122 | # undef __MATHDECL_1 |

123 | # define __MATHDECL_1(type, function, args) \ |

124 | extern type __REDIRECT_NTH(__MATH_PRECNAME(function), args, function) |

125 | # endif |

126 | |

127 | # define _Mdouble_ long double |

128 | # define __MATH_PRECNAME(name) name##l |

129 | # include <bits/cmathcalls.h> |

130 | #endif |

131 | #undef _Mdouble_ |

132 | #undef __MATH_PRECNAME |

133 | |

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 | |

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 | |

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 | |

218 | #undef __MATHDECL_1 |

219 | #undef __MATHDECL |

220 | #undef __MATHCALL |

221 | |

222 | __END_DECLS |

223 | |

224 | #endif /* complex.h */ |

225 |