1/*
2 * Copyright (c) 1999
3 * Boris Fomitchev
4 *
5 * This material is provided "as is", with absolutely no warranty expressed
6 * or implied. Any use is at your own risk.
7 *
8 * Permission to use or copy this software for any purpose is hereby granted
9 * without fee, provided the above notices are retained on all copies.
10 * Permission to modify the code and to distribute modified code is granted,
11 * provided the above notices are retained, and a notice that the code was
12 * modified is included with the above copyright notice.
13 *
14 */
15
16#ifndef _STLP_INTERNAL_CMATH
17#define _STLP_INTERNAL_CMATH
18
19/* gcc do not like when a using directive appear after a function
20 * declaration. cmath have abs overloads and cstdlib a using directive
21 * so cstdlib has to be included first.
22 */
23#if defined (__GNUC__) && defined (_STLP_USE_NEW_C_HEADERS)
24#  if defined (_STLP_HAS_INCLUDE_NEXT)
25#    include_next <cstdlib>
26#  else
27#    include _STLP_NATIVE_CPP_C_HEADER(cstdlib)
28#  endif
29#endif
30
31#if defined (_STLP_USE_NEW_C_HEADERS)
32#  if defined (_STLP_HAS_NO_NAMESPACES) && !defined (exception)
33#    define exception __math_exception
34#  endif
35#  if defined (_STLP_HAS_INCLUDE_NEXT)
36#    include_next <cmath>
37#  else
38#    include _STLP_NATIVE_CPP_C_HEADER(cmath)
39#  endif
40#  if defined (_STLP_HAS_NO_NAMESPACES)
41#    undef exception
42#  endif
43#else
44#  include <math.h>
45#endif
46
47#if (defined (__SUNPRO_CC) && (__SUNPRO_CC > 0x500)) || \
48     !(defined (__IBMCPP__) && (__IBMCPP__ >= 500) || !(defined(__HP_aCC) && (__HP_aCC >= 30000) ))
49#  if !defined(_STLP_HAS_NO_NAMESPACES) && !defined(__SUNPRO_CC)
50// All the other hypot stuff is going to be at file scope, so follow along here.
51namespace std {
52#  endif
53extern "C" double hypot(double x, double y);
54#  if !defined(_STLP_HAS_NO_NAMESPACES) && !defined(__SUNPRO_CC)
55}
56#  endif
57
58#endif
59
60#if defined (__sun) && defined (__GNUC__)
61extern "C" {
62  float __cosf(float v);
63  float __sinf(float v);
64  float __atan2f(float, float);
65  float __coshf(float v);
66  float __sinhf(float v);
67  float __sqrtf(float v);
68  float __expf(float v);
69  float __logf(float v);
70  float __log10f(float v);
71
72  long double __cosl(long double v);
73  long double __sinl(long double v);
74  long double __atan2l(long double, long double);
75  long double __coshl(long double v);
76  long double __sinhl(long double v);
77  long double __sqrtl(long double v);
78  long double __expl(long double v);
79  long double __logl(long double v);
80  long double __log10l(long double v);
81}
82
83extern "C" {
84  inline float cosf(float v) { return __cosf(v); }
85  inline float sinf(float v) { return __sinf(v); }
86  inline float atan2f(float v1, float v2) { return __atan2f(v1,v2); }
87  inline float coshf(float v) { return __coshf(v); }
88  inline float sinhf(float v) { return __sinhf(v); }
89  inline float sqrtf(float v) { return __sqrtf(v); }
90  inline float expf(float v) { return __expf(v); }
91  inline float logf(float v) { return __logf(v); }
92  inline float log10f(float v) { return __log10f(v); }
93
94  inline long double cosl(long double v) { return __cosl(v); }
95  inline long double sinl(long double v) { return __sinl(v); }
96  inline long double atan2l(long double v1, long double v2) { return __atan2l(v1,v2); }
97  inline long double coshl(long double v) { return __coshl(v); }
98  inline long double sinhl(long double v) { return __sinhl(v); }
99  inline long double sqrtl(long double v) { return __sqrtl(v); }
100  inline long double expl(long double v) { return __expl(v); }
101  inline long double logl(long double v) { return __logl(v); }
102  inline long double log10l(long double v) { return __log10l(v); }
103}
104#endif // __sun && __GNUC__
105
106#if defined (__sun)
107extern "C" {
108extern float __acosf(float);
109extern float __asinf(float);
110extern float __atanf(float);
111extern float __atan2f(float, float);
112extern float __ceilf(float);
113extern float __cosf(float);
114extern float __coshf(float);
115extern float __expf(float);
116extern float __fabsf(float);
117extern float __floorf(float);
118extern float __fmodf(float, float);
119extern float __frexpf(float, int *);
120extern float __ldexpf(float, int);
121extern float __logf(float);
122extern float __log10f(float);
123extern float __modff(float, float *);
124extern float __powf(float, float);
125extern float __sinf(float);
126extern float __sinhf(float);
127extern float __sqrtf(float);
128extern float __tanf(float);
129extern float __tanhf(float);
130
131extern long double __acosl(long double);
132extern long double __asinl(long double);
133extern long double __atanl(long double);
134extern long double __atan2l(long double, long double);
135extern long double __ceill(long double);
136extern long double __cosl(long double);
137extern long double __coshl(long double);
138extern long double __expl(long double);
139extern long double __fabsl(long double);
140extern long double __floorl(long double);
141extern long double __fmodl(long double, long double);
142extern long double __frexpl(long double, int *);
143extern long double __ldexpl(long double, int);
144extern long double __logl(long double);
145extern long double __log10l(long double);
146extern long double __modfl(long double, long double *);
147extern long double __powl(long double, long double);
148extern long double __sinl(long double);
149extern long double __sinhl(long double);
150extern long double __sqrtl(long double);
151extern long double __tanl(long double);
152extern long double __tanhl(long double);
153}
154#endif
155
156#if defined (__BORLANDC__)
157#  define _STLP_CMATH_FUNC_NAMESPACE _STLP_VENDOR_CSTD
158#else
159#  define _STLP_CMATH_FUNC_NAMESPACE
160#endif
161
162#if !defined (__sun) || defined (__GNUC__)
163#  define _STLP_MATH_INLINE(float_type, func, cfunc) \
164     inline float_type func (float_type x) { return _STLP_CMATH_FUNC_NAMESPACE::cfunc(x); }
165#  define _STLP_MATH_INLINE2(float_type, type, func, cfunc) \
166     inline float_type func (float_type x, type y) { return _STLP_CMATH_FUNC_NAMESPACE::cfunc(x, y); }
167#  define _STLP_MATH_INLINE_D(float_type, func, cfunc)
168#  define _STLP_MATH_INLINE2_D(float_type, type, func, cfunc)
169#else
170#  ifdef __SUNPRO_CC
171#    define _STLP_MATH_INLINE(float_type, func, cfunc) \
172       inline float_type func (float_type x) { return _STLP_VENDOR_CSTD::__##cfunc(x); }
173#    define _STLP_MATH_INLINE_D(float_type, func, cfunc) \
174       inline float_type func (float_type x) { return _STLP_VENDOR_CSTD::cfunc(x); }
175#    define _STLP_MATH_INLINE2(float_type, type, func, cfunc) \
176       inline float_type func (float_type x, type y) { return _STLP_VENDOR_CSTD::__##cfunc(x,y); }
177#    define _STLP_MATH_INLINE2_D(float_type, type, func, cfunc) \
178       inline float_type func (float_type x, type y) { return _STLP_VENDOR_CSTD::cfunc(x,y); }
179#  else
180#    error Unknown compiler for the Sun platform
181#  endif
182#endif
183
184/** macros to define math functions
185These macros (having an X somewhere in the name) forward to the C library's
186double functions but cast the arguments and return values to the given type. */
187
188#define _STLP_MATH_INLINEX(__type,func,cfunc) \
189  inline __type func (__type x) \
190  { return __STATIC_CAST(__type, _STLP_CMATH_FUNC_NAMESPACE::cfunc((double)x)); }
191#define _STLP_MATH_INLINE2X(__type1,__type2,func,cfunc) \
192  inline __type1 func (__type1 x, __type2 y) \
193  { return __STATIC_CAST(__type1, _STLP_CMATH_FUNC_NAMESPACE::cfunc((double)x, y)); }
194#define _STLP_MATH_INLINE2PX(__type,func,cfunc) \
195  inline __type func (__type x, __type *y) { \
196    double tmp1, tmp2; \
197    tmp1 = _STLP_CMATH_FUNC_NAMESPACE::cfunc(__STATIC_CAST(double, x), &tmp2); \
198    *y = __STATIC_CAST(__type, tmp2); \
199    return __STATIC_CAST(__type, tmp1); \
200  }
201#define _STLP_MATH_INLINE2XX(__type,func,cfunc) \
202  inline __type func (__type x, __type y) \
203  { return __STATIC_CAST(__type, _STLP_CMATH_FUNC_NAMESPACE::cfunc((double)x, (double)y)); }
204
205
206/** rough characterization of compiler and native C library
207For the compiler, it can either support long double or not. If it doesn't, the
208macro _STLP_NO_LONG_DOUBLE is defined and we don't define any long double
209overloads.
210For the native C library the question is whether it has variants with an 'f'
211suffix (for float as opposed to double) or an 'l' suffix (for long double). If
212the float variants are missing, _STLP_NO_VENDOR_MATH_F is defined, when the
213long double variants are missing, _STLP_NO_VENDOR_MATH_L is defined. Of course
214the latter doesn't make sense anyway when the compiler already has no long
215double support.
216
217Those two traits determine a) which overloads get defined and b) how they are
218defined.
219
220Meaning of suffixes:
221""   : function returning and taking a float_type
222"2"  : function returning a float_type and taking to float_types
223"2P" : function returning a float_type and taking a float_type and a float_type*
224"2PI": function returning a float_type and taking a float_type and an int*
225"2I" : function returning a float_type and taking a float_Type and an int
226*/
227
228#if !defined (_STLP_NO_LONG_DOUBLE) && !defined (_STLP_NO_VENDOR_MATH_L) && !defined (_STLP_NO_VENDOR_MATH_F)
229   // long double support and both e.g. sinl(long double) and sinf(float)
230   // This is the default for a correct and complete native library.
231#  define _STLP_DEF_MATH_INLINE(func,cf) \
232  _STLP_MATH_INLINE(float,func,cf##f) \
233  _STLP_MATH_INLINE_D(double,func,cf) \
234  _STLP_MATH_INLINE(long double,func,cf##l)
235#  define _STLP_DEF_MATH_INLINE2(func,cf) \
236  _STLP_MATH_INLINE2(float,float,func,cf##f) \
237  _STLP_MATH_INLINE2_D(double,double,func,cf) \
238  _STLP_MATH_INLINE2(long double,long double,func,cf##l)
239#  define _STLP_DEF_MATH_INLINE2P(func,cf) \
240  _STLP_MATH_INLINE2(float,float *,func,cf##f) \
241  _STLP_MATH_INLINE2_D(double,double *,func,cf) \
242  _STLP_MATH_INLINE2(long double,long double *,func,cf##l)
243#  define _STLP_DEF_MATH_INLINE2PI(func,cf) \
244  _STLP_MATH_INLINE2(float,int *,func,cf##f) \
245  _STLP_MATH_INLINE2_D(double,int *,func,cf) \
246  _STLP_MATH_INLINE2(long double,int *,func,cf##l)
247#  define _STLP_DEF_MATH_INLINE2I(func,cf) \
248  _STLP_MATH_INLINE2(float,int,func,cf##f) \
249  _STLP_MATH_INLINE2_D(double,int,func,cf) \
250  _STLP_MATH_INLINE2(long double,int,func,cf##l)
251#else
252#  if !defined (_STLP_NO_LONG_DOUBLE)
253#    if !defined (_STLP_NO_VENDOR_MATH_F)
254       // long double support and e.g. sinf(float) but not e.g. sinl(long double)
255#      define _STLP_DEF_MATH_INLINE(func,cf) \
256      _STLP_MATH_INLINE(float,func,cf##f) \
257      _STLP_MATH_INLINEX(long double,func,cf)
258#      define _STLP_DEF_MATH_INLINE2(func,cf) \
259      _STLP_MATH_INLINE2(float,float,func,cf##f) \
260      _STLP_MATH_INLINE2XX(long double,func,cf)
261#      define _STLP_DEF_MATH_INLINE2P(func,cf) \
262      _STLP_MATH_INLINE2(float,float *,func,cf##f) \
263      _STLP_MATH_INLINE2PX(long double,func,cf)
264#      define _STLP_DEF_MATH_INLINE2PI(func,cf) \
265      _STLP_MATH_INLINE2(float,int *,func,cf##f) \
266      _STLP_MATH_INLINE2X(long double,int *,func,cf)
267#      define _STLP_DEF_MATH_INLINE2I(func,cf) \
268      _STLP_MATH_INLINE2(float,int,func,cf##f) \
269      _STLP_MATH_INLINE2X(long double,int,func,cf)
270#    elif !defined (_STLP_NO_VENDOR_MATH_L)
271       // long double support and e.g. sinl(long double) but not e.g. sinf(float)
272#      define _STLP_DEF_MATH_INLINE(func,cf) \
273      _STLP_MATH_INLINEX(float,func,cf) \
274      _STLP_MATH_INLINE(long double,func,cf##l)
275#      define _STLP_DEF_MATH_INLINE2(func,cf) \
276      _STLP_MATH_INLINE2XX(float,func,cf) \
277      _STLP_MATH_INLINE2(long double,long double,func,cf##l)
278#      define _STLP_DEF_MATH_INLINE2P(func,cf) \
279      _STLP_MATH_INLINE2PX(float,func,cf) \
280      _STLP_MATH_INLINE2(long double,long double *,func,cf##l)
281#      define _STLP_DEF_MATH_INLINE2PI(func,cf) \
282      _STLP_MATH_INLINE2X(float,int *,func,cf) \
283      _STLP_MATH_INLINE2(long double,int *,func,cf##l)
284#      define _STLP_DEF_MATH_INLINE2I(func,cf) \
285      _STLP_MATH_INLINE2X(float,int,func,cf) \
286      _STLP_MATH_INLINE2(long double,int,func,cf##l)
287#    else
288#      define _STLP_DEF_MATH_INLINE(func,cf) \
289      _STLP_MATH_INLINEX(float,func,cf) \
290      _STLP_MATH_INLINEX(long double,func,cf)
291#      define _STLP_DEF_MATH_INLINE2(func,cf) \
292      _STLP_MATH_INLINE2XX(float,func,cf) \
293      _STLP_MATH_INLINE2XX(long double,func,cf)
294#      define _STLP_DEF_MATH_INLINE2P(func,cf) \
295      _STLP_MATH_INLINE2PX(float,func,cf) \
296      _STLP_MATH_INLINE2PX(long double,func,cf)
297#      define _STLP_DEF_MATH_INLINE2PI(func,cf) \
298      _STLP_MATH_INLINE2X(float,int *,func,cf) \
299      _STLP_MATH_INLINE2X(long double,int *,func,cf)
300#      define _STLP_DEF_MATH_INLINE2I(func,cf) \
301      _STLP_MATH_INLINE2X(float,int,func,cf) \
302      _STLP_MATH_INLINE2X(long double,int,func,cf)
303#    endif
304#  else
305#    if !defined (_STLP_NO_VENDOR_MATH_F)
306#      define _STLP_DEF_MATH_INLINE(func,cf) \
307      _STLP_MATH_INLINE(float,func,cf##f)
308#      define _STLP_DEF_MATH_INLINE2(func,cf) \
309      _STLP_MATH_INLINE2(float,float,func,cf##f)
310#      define _STLP_DEF_MATH_INLINE2P(func,cf) \
311      _STLP_MATH_INLINE2(float,float *,func,cf##f)
312#      define _STLP_DEF_MATH_INLINE2PI(func,cf) \
313      _STLP_MATH_INLINE2(float,int *,func,cf##f)
314#      define _STLP_DEF_MATH_INLINE2I(func,cf) \
315      _STLP_MATH_INLINE2(float,int,func,cf##f)
316#    else // _STLP_NO_VENDOR_MATH_F
317       // neither long double support nor e.g. sinf(float) functions
318#      define _STLP_DEF_MATH_INLINE(func,cf) \
319      _STLP_MATH_INLINEX(float,func,cf)
320#      define _STLP_DEF_MATH_INLINE2(func,cf) \
321      _STLP_MATH_INLINE2XX(float,func,cf)
322#      define _STLP_DEF_MATH_INLINE2P(func,cf) \
323      _STLP_MATH_INLINE2PX(float,func,cf)
324#      define _STLP_DEF_MATH_INLINE2PI(func,cf) \
325      _STLP_MATH_INLINE2X(float,int *,func,cf)
326#      define _STLP_DEF_MATH_INLINE2I(func,cf) \
327      _STLP_MATH_INLINE2X(float,int,func,cf)
328#    endif // _STLP_NO_VENDOR_MATH_F
329#  endif
330#endif
331
332#if defined (_STLP_WCE) || \
333   (defined(_STLP_MSVC) && (_STLP_MSVC <= 1300) && defined (_MSC_EXTENSIONS) /* && !defined(_STLP_WCE_NET) */)
334/*
335 * dums: VC6 has all the required C++ functions but only define them if
336 * _MSC_EXTENSIONS is not defined (a bug?). STLport just do the same
337 * thing also when _MSC_EXTENSIONS is defined.
338 * TODO: above check (_STLP_MSVC <= 1300) also catches VC7.0, is that intended?
339 */
340//We have to tell the compilers that abs, acos ... math functions are not intrinsic
341//otherwise we have Internal Compiler Error in release mode...
342#  pragma warning(push)
343#  pragma warning(disable: 4162) // no function with C linkage found
344#  pragma warning(disable: 4163) // not available as an intrinsic function
345#  pragma function (abs, acos, asin, atan, atan2, cos, cosh, exp, fabs, fmod, log, log10, sin, sinh, sqrt, tan, tanh)
346#  if defined (_STLP_WCE)
347#    pragma function (ceil, floor)
348#  endif
349#  define _STLP_RESTORE_FUNCTION_INTRINSIC
350#endif // _STLP_MSVC && _STLP_MSVC <= 1300 && !_STLP_WCE && _MSC_EXTENSIONS
351
352#if (defined (__BORLANDC__) || defined (__WATCOMC__)) && defined (_STLP_USE_NEW_C_HEADERS)
353/* In this config Borland native lib only define functions in std namespace.
354 * In order to have all overloads in STLport namespace we need to add the
355 * double overload in global namespace. We do not use a using statement to avoid
356 * import of invalid overload.
357 */
358#  define _STLP_DMATH_INLINE(func) _STLP_MATH_INLINE(double, func, func)
359#  define _STLP_DMATH_INLINE2(func) _STLP_MATH_INLINE2(double, double, func, func)
360
361_STLP_DMATH_INLINE(acos)
362_STLP_DMATH_INLINE(asin)
363_STLP_DMATH_INLINE(atan)
364_STLP_DMATH_INLINE2(atan2)
365_STLP_DMATH_INLINE(ceil)
366_STLP_DMATH_INLINE(cos)
367_STLP_DMATH_INLINE(cosh)
368_STLP_DMATH_INLINE(exp)
369_STLP_DMATH_INLINE(fabs)
370_STLP_DMATH_INLINE(floor)
371_STLP_DMATH_INLINE2(fmod)
372_STLP_MATH_INLINE2X(double, int*, frexp, frexp)
373_STLP_MATH_INLINE2X(double, int, ldexp, ldexp)
374_STLP_DMATH_INLINE(log)
375_STLP_DMATH_INLINE(log10)
376_STLP_MATH_INLINE2PX(double, modf, modf)
377_STLP_DMATH_INLINE(sin)
378_STLP_DMATH_INLINE(sinh)
379_STLP_DMATH_INLINE(sqrt)
380_STLP_DMATH_INLINE(tan)
381_STLP_DMATH_INLINE(tanh)
382_STLP_DMATH_INLINE2(pow)
383_STLP_DMATH_INLINE2(hypot)
384
385#  undef _STLP_DMATH_INLINE
386#  undef _STLP_DMATH_INLINE2
387#endif
388
389#if defined (__DMC__)
390#  if defined (fabs)
391inline double __stlp_fabs(double __x) { return fabs(__x); }
392#    undef fabs
393inline double fabs(double __x) { return __stlp_fabs(__x); }
394#  endif
395#  if defined (cos)
396inline double __stlp_cos(double __x) { return cos(__x); }
397#    undef cos
398inline double cos(double __x) { return __stlp_cos(__x); }
399#  endif
400#  if defined (sin)
401inline double __stlp_sin(double __x) { return sin(__x); }
402#    undef sin
403inline double sin(double __x) { return __stlp_sin(__x); }
404#  endif
405#  if defined (sqrt)
406inline double __stlp_sqrt(double __x) { return sqrt(__x); }
407#    undef sqrt
408inline double sqrt(double __x) { return __stlp_sqrt(__x); }
409#  endif
410#  if defined (ldexp)
411inline double __stlp_ldexp(double __x, int __y) { return ldexp(__x, __y); }
412#    undef ldexp
413inline double ldexp(double __x, int __y) { return __stlp_ldexp(__x, __y); }
414#  endif
415#endif
416
417/* MSVC native lib starting with .Net 2003 has already all math functions
418 * in global namespace.
419 * HP-UX native lib has math functions in the global namespace.
420 */
421#if (!defined (_STLP_MSVC_LIB) || (_STLP_MSVC_LIB < 1310) || defined(UNDER_CE)) && \
422    (!defined (__HP_aCC) || (__HP_aCC < 30000)) && \
423    !defined (__WATCOMC__)
424inline double abs(double __x)
425{ return ::fabs(__x); }
426#  if !defined (__MVS__)
427_STLP_DEF_MATH_INLINE(abs, fabs)
428#  else // __MVS__ has native long double abs?
429inline float abs(float __x) { return ::fabsf(__x); }
430#  endif
431
432_STLP_DEF_MATH_INLINE(acos, acos)
433_STLP_DEF_MATH_INLINE(asin, asin)
434_STLP_DEF_MATH_INLINE(atan, atan)
435_STLP_DEF_MATH_INLINE2(atan2, atan2)
436_STLP_DEF_MATH_INLINE(ceil, ceil)
437_STLP_DEF_MATH_INLINE(cos, cos)
438_STLP_DEF_MATH_INLINE(cosh, cosh)
439_STLP_DEF_MATH_INLINE(exp, exp)
440_STLP_DEF_MATH_INLINE(fabs, fabs)
441_STLP_DEF_MATH_INLINE(floor, floor)
442_STLP_DEF_MATH_INLINE2(fmod, fmod)
443_STLP_DEF_MATH_INLINE2PI(frexp, frexp)
444_STLP_DEF_MATH_INLINE2I(ldexp, ldexp)
445_STLP_DEF_MATH_INLINE(log, log)
446_STLP_DEF_MATH_INLINE(log10, log10)
447_STLP_DEF_MATH_INLINE2P(modf, modf)
448_STLP_DEF_MATH_INLINE(sin, sin)
449_STLP_DEF_MATH_INLINE(sinh, sinh)
450_STLP_DEF_MATH_INLINE(sqrt, sqrt)
451_STLP_DEF_MATH_INLINE(tan, tan)
452_STLP_DEF_MATH_INLINE(tanh, tanh)
453_STLP_DEF_MATH_INLINE2(pow, pow)
454
455#  if !defined(_STLP_MSVC) /* || (_STLP_MSVC > 1300) */ || defined(_STLP_WCE) || !defined (_MSC_EXTENSIONS) /* && !defined(_STLP_WCE_NET) */
456#    ifndef _STLP_NO_VENDOR_MATH_F
457#      ifndef __sun
458inline float pow(float __x, int __y) { return _STLP_CMATH_FUNC_NAMESPACE::powf(__x, __STATIC_CAST(float,__y)); }
459#      else
460inline float pow(float __x, int __y) { return ::__powf(__x, __STATIC_CAST(float,__y)); }
461#      endif
462#    else
463inline float pow(float __x, int __y) { return __STATIC_CAST(float, _STLP_CMATH_FUNC_NAMESPACE::pow(__x, __STATIC_CAST(float,__y))); }
464#    endif
465inline double pow(double __x, int __y) { return _STLP_CMATH_FUNC_NAMESPACE::pow(__x, __STATIC_CAST(double,__y)); }
466#    if !defined (_STLP_NO_LONG_DOUBLE)
467#      if !defined(_STLP_NO_VENDOR_MATH_L)
468#        ifndef __sun
469inline long double pow(long double __x, int __y) { return _STLP_CMATH_FUNC_NAMESPACE::powl(__x, __STATIC_CAST(long double,__y)); }
470#        else
471#          ifndef __SUNPRO_CC
472inline long double pow(long double __x, int __y) { return ::__powl(__x, __STATIC_CAST(long double,__y)); }
473#          else
474inline long double pow(long double __x, int __y) { return _STLP_VENDOR_CSTD::__powl(__x, __STATIC_CAST(long double,__y)); }
475#          endif
476#        endif
477#      else
478inline long double pow(long double __x, int __y) { return __STATIC_CAST(long double, _STLP_CMATH_FUNC_NAMESPACE::pow(__x, __STATIC_CAST(long double,__y))); }
479#      endif
480#    endif
481#  else
482//The MS native pow version has a bugged overload so it is not imported
483//in the STLport namespace.
484//Here is the bugged version:
485//inline double pow(int __x, int __y)            { return (_Pow_int(__x, __y)); }
486inline double      pow(double __x, int __y)      { return (_Pow_int(__x, __y)); }
487inline float       pow(float __x, int __y)       { return (_Pow_int(__x, __y)); }
488inline long double pow(long double __x, int __y) { return (_Pow_int(__x, __y)); }
489#  endif
490#endif
491
492#if (defined (_STLP_MSVC) && !defined (_STLP_WCE)) || defined (__ICL) || defined (__sun)
493#  if defined (_STLP_MSVC) && (_STLP_MSVC >= 1400)
494#    pragma warning (push)
495#    pragma warning (disable : 4996) // hypot is deprecated.
496#  endif
497_STLP_MATH_INLINE2XX(float, hypot, hypot)
498inline long double hypot(long double x, long double y) { return sqrt(x * x + y * y); }
499#  if defined (_STLP_MSVC) && (_STLP_MSVC >= 1400)
500#    pragma warning (pop)
501#  endif
502#else
503#  if defined (_STLP_USE_UCLIBC)
504inline double hypot(double x, double y) { return sqrt(x * x + y * y); }
505_STLP_DEF_MATH_INLINE2(hypot, hypot)
506#  elif defined (_STLP_WCE)
507   /* CE has a double _hypot(double,double) which we use */
508inline double hypot(double __x, double __y) { return _hypot(__x,__y); }
509_STLP_DEF_MATH_INLINE2(hypot, _hypot)
510#  endif
511#endif
512
513#if defined (_STLP_RESTORE_FUNCTION_INTRINSIC)
514//restoration of the default intrinsic status of those functions:
515#  pragma intrinsic (abs, acos, asin, atan, atan2, cos, cosh, exp, fabs, fmod, log, log10, sin, sinh, sqrt, tan, tanh)
516#  if defined (_STLP_WCE)
517#    pragma intrinsic (ceil, floor)
518#  endif
519#  pragma warning(pop)
520#  undef _STLP_RESTORE_FUNCTION_INTRINSIC
521#endif // _STLP_MSVC && _STLP_MSVC <= 1300 && !_STLP_WCE && _MSC_EXTENSIONS
522
523/* C++ Standard is unclear about several call to 'using ::func' if new overloads
524 * of ::func appears between 2 successive 'using' calls. To avoid this potential
525 * problem we provide all abs overload before the 'using' call.
526 * Beware: This header inclusion has to be after all abs overload of this file.
527 *         The first 'using ::abs' call is going to be in the other header.
528 */
529#ifndef _STLP_INTERNAL_CSTDLIB
530#  include <stl/_cstdlib.h>
531#endif
532
533#if defined (_STLP_IMPORT_VENDOR_CSTD) && !defined (_STLP_NO_CSTD_FUNCTION_IMPORTS)
534#if defined (__ANDROID__)
535namespace __captured {
536template<typename _Tp> inline int __capture_isfinite(_Tp __f) { return isfinite(__f); }
537template<typename _Tp> inline int __capture_isinf(_Tp __f) { return isinf(__f); }
538template<typename _Tp> inline int __capture_isnan(_Tp __f) { return isnan(__f); }
539template<typename _Tp> inline int __capture_signbit(_Tp __f) { return signbit(__f); }
540}
541#undef isfinite
542#undef isinf
543#undef isnan
544#undef signbit
545namespace __captured {
546template<typename _Tp> inline int isfinite(_Tp __f) { return __capture_isfinite(__f); }
547template<typename _Tp> inline int isinf(_Tp __f) { return __capture_isinf(__f); }
548template<typename _Tp> inline int isnan(_Tp __f) { return __capture_isnan(__f); }
549template<typename _Tp> inline int signbit(_Tp __f) { return __capture_signbit(__f); }
550}
551#endif
552_STLP_BEGIN_NAMESPACE
553using ::abs;
554using ::acos;
555using ::asin;
556using ::atan;
557using ::atan2;
558using ::ceil;
559using ::cos;
560using ::cosh;
561using ::exp;
562using ::fabs;
563using ::floor;
564using ::fmod;
565using ::frexp;
566/*
567   Because of some weird interaction between STLport headers
568   and native HP-UX headers, when compiled with _STLP_DEBUG
569   macro defined with aC++, hypot() is not declared.
570   At some point we'll need to get to the bottom line of
571   this problem.
572*/
573#if !(defined(__HP_aCC) && defined(_STLP_DEBUG))
574using ::hypot;
575#endif
576#if defined (__ANDROID__)
577using __captured::isfinite;
578using __captured::isinf;
579using __captured::isnan;
580#endif
581using ::ldexp;
582using ::log;
583using ::log10;
584using ::modf;
585using ::pow;
586#if defined (__ANDROID__)
587using __captured::signbit;
588#endif
589using ::sin;
590using ::sinh;
591using ::sqrt;
592using ::tan;
593using ::tanh;
594_STLP_END_NAMESPACE
595#  if defined (__BORLANDC__) && (__BORLANDC__ >= 0x560) && !defined (__linux__)
596using _STLP_VENDOR_CSTD::_ecvt;
597using _STLP_VENDOR_CSTD::_fcvt;
598#  endif
599#endif
600
601#endif /* _STLP_INTERNAL_CMATH */
602
603// Local Variables:
604// mode:C++
605// End:
606