YSTest: cmath.h 源文件

YSTest PreAlpha_b800_20170810 The YSLib Test Project

- 首页
- 相关页面
- 模块
- 命名空间
- 类
- 文件

- 文件列表
- 文件成员

cmath.h
浏览该文件的文档.
1 /*
2 © 2014-2016 FrankHB.
3
4 This file is part of the YSLib project, and may only be used,
5 modified, and distributed under the terms of the YSLib project
6 license, LICENSE.TXT. By continuing to use, modify, or distribute
7 this file you indicate that you have read the license and
8 understand and accept it fully.
9 */
10
28 #ifndef YB_INC_libdefect_cmath_h_
29 #define YB_INC_libdefect_cmath_h_ 1
30
31 #include <cmath>
32
33 #if defined(__GLIBCXX__) \
34 && (defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L) \
35 && !(defined(_GLIBCXX_USE_C99_MATH_TR1))
36
37 namespace std _GLIBCXX_VISIBILITY(default)
38 {
39
40 #undef acosh
41 #undef acoshf
42 #undef acoshl
43 #undef asinh
44 #undef asinhf
45 #undef asinhl
46 #undef atanh
47 #undef atanhf
48 #undef atanhl
49 #undef cbrt
50 #undef cbrtf
51 #undef cbrtl
52 #undef copysign
53 #undef copysignf
54 #undef copysignl
55 #undef erf
56 #undef erff
57 #undef erfl
58 #undef erfc
59 #undef erfcf
60 #undef erfcl
61 #undef exp2
62 #undef exp2f
63 #undef exp2l
64 #undef expm1
65 #undef expm1f
66 #undef expm1l
67 #undef fdim
68 #undef fdimf
69 #undef fdiml
70 #undef fma
71 #undef fmaf
72 #undef fmal
73 #undef fmax
74 #undef fmaxf
75 #undef fmaxl
76 #undef fmin
77 #undef fminf
78 #undef fminl
79 #undef hypot
80 #undef hypotf
81 #undef hypotl
82 #undef ilogb
83 #undef ilogbf
84 #undef ilogbl
85 #undef lgamma
86 #undef lgammaf
87 #undef lgammal
88 #undef llrint
89 #undef llrintf
90 #undef llrintl
91 #undef llround
92 #undef llroundf
93 #undef llroundl
94 #undef log1p
95 #undef log1pf
96 #undef log1pl
97 #undef log2
98 #undef log2f
99 #undef log2l
100 #undef logb
101 #undef logbf
102 #undef logbl
103 #undef lrint
104 #undef lrintf
105 #undef lrintl
106 #undef lround
107 #undef lroundf
108 #undef lroundl
109 #undef nan
110 #undef nanf
111 #undef nanl
112 #undef nearbyint
113 #undef nearbyintf
114 #undef nearbyintl
115 #undef nextafter
116 #undef nextafterf
117 #undef nextafterl
118 #undef nexttoward
119 #undef nexttowardf
120 #undef nexttowardl
121 #undef remainder
122 #undef remainderf
123 #undef remainderl
124 #undef remquo
125 #undef remquof
126 #undef remquol
127 #undef rint
128 #undef rintf
129 #undef rintl
130 #undef round
131 #undef roundf
132 #undef roundl
133 #undef scalbln
134 #undef scalblnf
135 #undef scalblnl
136 #undef scalbn
137 #undef scalbnf
138 #undef scalbnl
139 #undef tgamma
140 #undef tgammaf
141 #undef tgammal
142 #undef trunc
143 #undef truncf
144 #undef truncl
145
146
147 #ifdef __BIONIC__
148 using float_t = float;
149 using double_t = double;
150 #else
151 using ::double_t;
152 using ::float_t;
153 #endif
154
155 // TODO: Deferred. How to detect if 'long double' available?
156 # define YB_LibDefect_CMath_using_f(_fn) \
157 using ::_fn; \
158 using ::_fn##f;
159 # define YB_LibDefect_CMath_using_fl(_fn) \
160 YB_LibDefect_CMath_using_f(_fn) \
161 using ::_fn##l;
162
163 #ifndef __BIONIC__
164 # define YB_LibDefect_CMath_using(_fn) \
165 YB_LibDefect_CMath_using_fl(_fn)
166 #else
167 # define YB_LibDefect_CMath_using(_fn) \
168 YB_LibDefect_CMath_using_f(_fn)
169 #endif
170
171 YB_LibDefect_CMath_using(acos)
172 YB_LibDefect_CMath_using(asin)
173 YB_LibDefect_CMath_using(atan)
174 YB_LibDefect_CMath_using(cbrt)
175 YB_LibDefect_CMath_using(copysign)
176 YB_LibDefect_CMath_using(erf)
177 YB_LibDefect_CMath_using(erfc)
178 YB_LibDefect_CMath_using(exp2)
179 YB_LibDefect_CMath_using(expm1)
180 YB_LibDefect_CMath_using(fdim)
181 YB_LibDefect_CMath_using(fma)
182 YB_LibDefect_CMath_using(fmax)
183 YB_LibDefect_CMath_using(fmin)
184 YB_LibDefect_CMath_using(hypot)
185 YB_LibDefect_CMath_using(ilogb)
186 YB_LibDefect_CMath_using(lgamma)
187 YB_LibDefect_CMath_using(llrint)
188 YB_LibDefect_CMath_using(llround)
189 YB_LibDefect_CMath_using(log1p)
190 #ifndef __BIONIC__
191 # ifndef _NEWLIB_VERSION
192 YB_LibDefect_CMath_using(log2)
193 # else
194 YB_LibDefect_CMath_using_f(log2)
195 # endif
196 #endif
197 #ifndef _NEWLIB_VERSION
198 YB_LibDefect_CMath_using_f(logb)
199 #else
200 YB_LibDefect_CMath_using(lrint)
201 #endif
202 YB_LibDefect_CMath_using(lround)
203 #ifndef __BIONIC__
204 YB_LibDefect_CMath_using(nan)
205 #endif
206 YB_LibDefect_CMath_using(nearbyint)
207 YB_LibDefect_CMath_using(nextafter)
208 #ifndef _NEWLIB_VERSION
209 YB_LibDefect_CMath_using(nexttoward)
210 #endif
211 YB_LibDefect_CMath_using(remainder)
212 YB_LibDefect_CMath_using(remquo)
213 YB_LibDefect_CMath_using(rint)
214 YB_LibDefect_CMath_using(round)
215 YB_LibDefect_CMath_using(scalbln)
216 YB_LibDefect_CMath_using(scalbn)
217 #ifndef __BIONIC__
218 YB_LibDefect_CMath_using(tgamma)
219 #else
220 using ::tgamma;
221 #endif
222 YB_LibDefect_CMath_using(trunc)
223
224 #undef YB_LibDefect_CMath_using
225 #undef YB_LibDefect_CMath_using_fl
226 #undef YB_LibDefect_CMath_using_f
227
228 #if __clang__
229 // NOTE: See also https://llvm.org/bugs/show_bug.cgi?id=18327.
230 # define YB_LibDefect_CMath_constexpr inline
231 #else
232 # define YB_LibDefect_CMath_constexpr constexpr
233 #endif
234
235 #define YB_LibDefect_CMath_builtin(_n, ...) \
236 { \
237 return __builtin_##_n(__VA_ARGS__); \
238 }
239 #define YB_LibDefect_CMath_fn(_t, _fn, _n) \
240 YB_LibDefect_CMath_constexpr _t \
241 _fn(_t __x) \
242 YB_LibDefect_CMath_builtin(_n, __x)
243 #define YB_LibDefect_CMath_fn2(_t, _fn, _n) \
244 YB_LibDefect_CMath_constexpr _t \
245 _fn(_t __x, _t __y) \
246 YB_LibDefect_CMath_builtin(_n, __x, __y)
247 #define YB_LibDefect_CMath_fns(_fn) \
248 YB_LibDefect_CMath_fn(float, _fn, _fn##f) \
249 YB_LibDefect_CMath_fn(long double, _fn, _fn##l) \
250 template<typename _Tp> \
251 YB_LibDefect_CMath_constexpr typename \
252 __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, double>::__type \
253 _fn(_Tp __x) \
254 YB_LibDefect_CMath_builtin(_fn, __x)
255 #define YB_LibDefect_CMath_fns2(_fn) \
256 YB_LibDefect_CMath_fn2(float, _fn, _fn##f) \
257 YB_LibDefect_CMath_fn2(long double, _fn, _fn##l) \
258 template<typename _Tp, typename _Up> \
259 YB_LibDefect_CMath_constexpr \
260 typename __gnu_cxx::__promote_2<_Tp, _Up>::__type \
261 _fn(_Tp __x, _Up __y) \
262 { \
263 using __type = typename __gnu_cxx::__promote_2<_Tp, _Up>::__type; \
264 \
265 return _fn(__type(__x), __type(__y)); \
266 }
267
268 #define YB_LibDefect_CMath_trigo(_n) \
269 YB_LibDefect_CMath_fns(a##_n##h)
270
271 YB_LibDefect_CMath_trigo(cos)
272
273 YB_LibDefect_CMath_trigo(sin)
274
275 YB_LibDefect_CMath_trigo(tan)
276
277 #undef YB_LibDefect_CMath_trigo
278
279 YB_LibDefect_CMath_fns(cbrt)
280
281 YB_LibDefect_CMath_fns2(copysign)
282
283 YB_LibDefect_CMath_fns(erf)
284
285 YB_LibDefect_CMath_fns(erfc)
286
287 YB_LibDefect_CMath_fns(exp2)
288
289 YB_LibDefect_CMath_fns(expm1)
290
291 YB_LibDefect_CMath_fns2(fdim)
292
293 YB_LibDefect_CMath_constexpr float
294 fma(float __x, float __y, float __z)
295 YB_LibDefect_CMath_builtin(fmaf, __x, __y, __z)
296 YB_LibDefect_CMath_constexpr long double
297 fma(long double __x, long double __y, long double __z)
298 YB_LibDefect_CMath_builtin(fmal, __x, __y, __z)
299 template<typename _Tp, typename _Up, typename _Vp>
300 YB_LibDefect_CMath_constexpr \
301 typename __gnu_cxx::__promote_3<_Tp, _Up, _Vp>::__type
302 fma(_Tp __x, _Up __y, _Vp __z)
303 {
304 using __type = typename __gnu_cxx::__promote_3<_Tp, _Up, _Vp>::__type;
305
306 return fma(__type(__x), __type(__y), __type(__z));
307 }
308
309 YB_LibDefect_CMath_fns2(fmax)
310
311 YB_LibDefect_CMath_fns2(fmin)
312
313 YB_LibDefect_CMath_fns2(hypot)
314
315 YB_LibDefect_CMath_fns(ilogb)
316
317 YB_LibDefect_CMath_fns(lgamma)
318
319 YB_LibDefect_CMath_fns(llrint)
320
321 YB_LibDefect_CMath_fns(llround)
322
323 YB_LibDefect_CMath_fns(log1p)
324
325 // DR 568.
326 YB_LibDefect_CMath_fns(log2)
327
328 YB_LibDefect_CMath_fns(logb)
329
330 YB_LibDefect_CMath_fns(lrint)
331
332 YB_LibDefect_CMath_fns(lround)
333
334 YB_LibDefect_CMath_fns(nearbyint)
335
336 YB_LibDefect_CMath_fns2(nextafter)
337
338 YB_LibDefect_CMath_constexpr float
339 nexttoward(float __x, long double __y)
340 YB_LibDefect_CMath_builtin(nexttowardf, __x, __y)
341 YB_LibDefect_CMath_constexpr long double
342 nexttoward(long double __x, long double __y)
343 YB_LibDefect_CMath_builtin(nexttowardl, __x, __y)
344 template<typename _Tp>
345 YB_LibDefect_CMath_constexpr
346 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, double>::__type
347 nexttoward(_Tp __x, long double __y)
348 YB_LibDefect_CMath_builtin(nexttoward, __x, __y)
349
350 YB_LibDefect_CMath_fns2(remainder)
351
352 inline float
353 remquo(float __x, float __y, int* __pquo)
354 YB_LibDefect_CMath_builtin(remquof, __x, __y, __pquo)
355 inline long double
356 remquo(long double __x, long double __y, int* __pquo)
357 YB_LibDefect_CMath_builtin(remquol, __x, __y, __pquo)
358 template<typename _Tp, typename _Up>
359 inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
360 remquo(_Tp __x, _Up __y, int* __pquo)
361 {
362 using __type = typename __gnu_cxx::__promote_2<_Tp, _Up>::__type;
363
364 return remquo(__type(__x), __type(__y), __pquo);
365 }
366
367 YB_LibDefect_CMath_fns(rint)
368
369 YB_LibDefect_CMath_fns(round)
370
371 YB_LibDefect_CMath_constexpr float
372 scalbln(float __x, long __ex)
373 YB_LibDefect_CMath_builtin(scalblnf, __x, __ex)
374 YB_LibDefect_CMath_constexpr long double
375 scalbln(long double __x, long __ex)
376 YB_LibDefect_CMath_builtin(scalblnl, __x, __ex)
377 template<typename _Tp>
378 YB_LibDefect_CMath_constexpr
379 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, double>::__type
380 scalbln(_Tp __x, long __ex)
381 YB_LibDefect_CMath_builtin(scalbln, __x, __ex)
382
383 YB_LibDefect_CMath_constexpr float
384 scalbn(float __x, int __ex)
385 YB_LibDefect_CMath_builtin(scalbnf, __x, __ex)
386 YB_LibDefect_CMath_constexpr long double
387 scalbn(long double __x, int __ex)
388 YB_LibDefect_CMath_builtin(scalbnl, __x, __ex)
389 template<typename _Tp>
390 YB_LibDefect_CMath_constexpr
391 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, double>::__type
392 scalbn(_Tp __x, int __ex)
393 YB_LibDefect_CMath_builtin(scalbn, __x, __ex)
394
395 YB_LibDefect_CMath_fns(tgamma)
396
397 YB_LibDefect_CMath_fns(trunc)
398
399 #undef YB_LibDefect_CMath_fns
400 #undef YB_LibDefect_CMath_fn2
401 #undef YB_LibDefect_CMath_fn
402 #undef YB_LibDefect_CMath_builtin
403 #undef YB_LibDefect_CMath_constexpr
404
405 } // namespace std;
406
407 #endif
408
409 #endif
410
std
Definition: memory.hpp:1183