YSTest: cmath.h 源文件

YSTest PreAlpha_b700_20160611 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 #define YB_LibDefect_CMath_builtin(_n, ...) \
229 { \
230 return __builtin_##_n(__VA_ARGS__); \
231 }
232 #define YB_LibDefect_CMath_fn(_t, _fn, _n) \
233 constexpr _t \
234 _fn(_t __x) \
235 YB_LibDefect_CMath_builtin(_n, __x)
236 #define YB_LibDefect_CMath_fn2(_t, _fn, _n) \
237 constexpr _t \
238 _fn(_t __x, _t __y) \
239 YB_LibDefect_CMath_builtin(_n, __x, __y)
240 #define YB_LibDefect_CMath_fns(_fn) \
241 YB_LibDefect_CMath_fn(float, _fn, _fn##f) \
242 YB_LibDefect_CMath_fn(long double, _fn, _fn##l) \
243 template<typename _Tp> \
244 constexpr typename \
245 __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, double>::__type \
246 _fn(_Tp __x) \
247 YB_LibDefect_CMath_builtin(_fn, __x)
248 #define YB_LibDefect_CMath_fns2(_fn) \
249 YB_LibDefect_CMath_fn2(float, _fn, _fn##f) \
250 YB_LibDefect_CMath_fn2(long double, _fn, _fn##l) \
251 template<typename _Tp, typename _Up> \
252 constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type \
253 _fn(_Tp __x, _Up __y) \
254 { \
255 using __type = typename __gnu_cxx::__promote_2<_Tp, _Up>::__type; \
256 \
257 return _fn(__type(__x), __type(__y)); \
258 }
259
260 #define YB_LibDefect_CMath_trigo(_n) \
261 YB_LibDefect_CMath_fns(a##_n##h)
262
263 YB_LibDefect_CMath_trigo(cos)
264
265 YB_LibDefect_CMath_trigo(sin)
266
267 YB_LibDefect_CMath_trigo(tan)
268
269 #undef YB_LibDefect_CMath_trigo
270
271 YB_LibDefect_CMath_fns(cbrt)
272
273 YB_LibDefect_CMath_fns2(copysign)
274
275 YB_LibDefect_CMath_fns(erf)
276
277 YB_LibDefect_CMath_fns(erfc)
278
279 YB_LibDefect_CMath_fns(exp2)
280
281 YB_LibDefect_CMath_fns(expm1)
282
283 YB_LibDefect_CMath_fns2(fdim)
284
285 constexpr float
286 fma(float __x, float __y, float __z)
287 YB_LibDefect_CMath_builtin(fmaf, __x, __y, __z)
288 constexpr long double
289 fma(long double __x, long double __y, long double __z)
290 YB_LibDefect_CMath_builtin(fmal, __x, __y, __z)
291 template<typename _Tp, typename _Up, typename _Vp>
292 constexpr typename __gnu_cxx::__promote_3<_Tp, _Up, _Vp>::__type
293 fma(_Tp __x, _Up __y, _Vp __z)
294 {
295 using __type = typename __gnu_cxx::__promote_3<_Tp, _Up, _Vp>::__type;
296
297 return fma(__type(__x), __type(__y), __type(__z));
298 }
299
300 YB_LibDefect_CMath_fns2(fmax)
301
302 YB_LibDefect_CMath_fns2(fmin)
303
304 YB_LibDefect_CMath_fns2(hypot)
305
306 YB_LibDefect_CMath_fns(ilogb)
307
308 YB_LibDefect_CMath_fns(lgamma)
309
310 YB_LibDefect_CMath_fns(llrint)
311
312 YB_LibDefect_CMath_fns(llround)
313
314 YB_LibDefect_CMath_fns(log1p)
315
316 // DR 568.
317 YB_LibDefect_CMath_fns(log2)
318
319 YB_LibDefect_CMath_fns(logb)
320
321 YB_LibDefect_CMath_fns(lrint)
322
323 YB_LibDefect_CMath_fns(lround)
324
325 YB_LibDefect_CMath_fns(nearbyint)
326
327 YB_LibDefect_CMath_fns2(nextafter)
328
329 constexpr float
330 nexttoward(float __x, long double __y)
331 YB_LibDefect_CMath_builtin(nexttowardf, __x, __y)
332 constexpr long double
333 nexttoward(long double __x, long double __y)
334 YB_LibDefect_CMath_builtin(nexttowardl, __x, __y)
335 template<typename _Tp>
336 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
337 double>::__type
338 nexttoward(_Tp __x, long double __y)
339 YB_LibDefect_CMath_builtin(nexttoward, __x, __y)
340
341 YB_LibDefect_CMath_fns2(remainder)
342
343 inline float
344 remquo(float __x, float __y, int* __pquo)
345 YB_LibDefect_CMath_builtin(remquof, __x, __y, __pquo)
346 inline long double
347 remquo(long double __x, long double __y, int* __pquo)
348 YB_LibDefect_CMath_builtin(remquol, __x, __y, __pquo)
349 template<typename _Tp, typename _Up>
350 inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
351 remquo(_Tp __x, _Up __y, int* __pquo)
352 {
353 using __type = typename __gnu_cxx::__promote_2<_Tp, _Up>::__type;
354
355 return remquo(__type(__x), __type(__y), __pquo);
356 }
357
358 YB_LibDefect_CMath_fns(rint)
359
360 YB_LibDefect_CMath_fns(round)
361
362 constexpr float
363 scalbln(float __x, long __ex)
364 YB_LibDefect_CMath_builtin(scalblnf, __x, __ex)
365 constexpr long double
366 scalbln(long double __x, long __ex)
367 YB_LibDefect_CMath_builtin(scalblnl, __x, __ex)
368 template<typename _Tp>
369 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
370 double>::__type
371 scalbln(_Tp __x, long __ex)
372 YB_LibDefect_CMath_builtin(scalbln, __x, __ex)
373
374 constexpr float
375 scalbn(float __x, int __ex)
376 YB_LibDefect_CMath_builtin(scalbnf, __x, __ex)
377 constexpr long double
378 scalbn(long double __x, int __ex)
379 YB_LibDefect_CMath_builtin(scalbnl, __x, __ex)
380 template<typename _Tp>
381 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
382 double>::__type
383 scalbn(_Tp __x, int __ex)
384 YB_LibDefect_CMath_builtin(scalbn, __x, __ex)
385
386 YB_LibDefect_CMath_fns(tgamma)
387
388 YB_LibDefect_CMath_fns(trunc)
389
390 #undef YB_LibDefect_CMath_fns
391 #undef YB_LibDefect_CMath_fn2
392 #undef YB_LibDefect_CMath_fn
393 #undef YB_LibDefect_CMath_builtin
394
395 } // namespace std;
396
397 #endif
398
399 #endif
400
std
Definition: memory.hpp:1100