src/libm/math.h
changeset 3012 7e30c2dc7783
parent 2859 99210400e8b9
child 3697 f7b03b6838cb
     1.1 --- a/src/libm/math.h	Fri Jan 09 20:43:30 2009 +0000
     1.2 +++ b/src/libm/math.h	Sat Jan 10 18:32:24 2009 +0000
     1.3 @@ -20,34 +20,56 @@
     1.4      slouken@libsdl.org
     1.5  */
     1.6  #include "SDL_config.h"
     1.7 -
     1.8 -#ifdef HAVE_MATH_H
     1.9 -#define _USE_MATH_DEFINES
    1.10 -#include <math.h>
    1.11 -#else
    1.12 +#include "SDL_stdinc.h"
    1.13  
    1.14  /* Math routines from uClibc: http://www.uclibc.org */
    1.15  
    1.16 -#define M_PI    3.14159265358979323846264338327950288   /* pi */
    1.17 +#ifdef HAVE_COPYSIGN
    1.18 +#define copysign        SDL_uclibc_copysign
    1.19 +#else
    1.20 +#define copysign        SDL_copysign
    1.21 +#endif
    1.22 +
    1.23 +#ifdef HAVE_COS
    1.24 +#define cos             SDL_uclibc_cos
    1.25 +#else
    1.26 +#define cos             SDL_cos
    1.27 +#endif
    1.28  
    1.29 -extern double __ieee754_log(double x);
    1.30 -extern double __ieee754_pow(double x, double y);
    1.31 -extern double __ieee754_sqrt(double x);
    1.32 +#ifdef HAVE_FABS
    1.33 +#define fabs            SDL_uclibc_fabs
    1.34 +#else
    1.35 +#define fabs            SDL_fabs
    1.36 +#endif
    1.37  
    1.38 -#define log(x)      __ieee754_log(x)
    1.39 -#define pow(x, y)   __ieee754_pow(x, y)
    1.40 -#define sqrt(x)     __ieee754_sqrt(x)
    1.41 +#ifdef HAVE_FLOOR
    1.42 +#define floor           SDL_uclibc_floor
    1.43 +#else
    1.44 +#define floor           SDL_floor
    1.45 +#endif
    1.46  
    1.47 -extern double copysign(double x, double y);
    1.48 -extern double cos(double x);
    1.49 -extern double fabs(double x);
    1.50 -extern double floor(double x);
    1.51 -extern double scalbn(double x, int n);
    1.52 -extern double sin(double x);
    1.53 +#ifndef HAVE_LOG
    1.54 +#define __ieee754_log   SDL_log
    1.55 +#endif
    1.56 +
    1.57 +#ifndef HAVE_POW
    1.58 +#define __ieee754_pow   SDL_pow
    1.59 +#endif
    1.60  
    1.61 -#define sinf(x) (float)sin((double)x)
    1.62 -#define cosf(x) (float)cos((double)x)
    1.63 +#ifdef HAVE_SCALBN
    1.64 +#define scalbn          SDL_uclibc_scalbn
    1.65 +#else
    1.66 +#define scalbn          SDL_scalbn
    1.67 +#endif
    1.68  
    1.69 -#endif /* HAVE_MATH_H */
    1.70 +#ifdef HAVE_SIN
    1.71 +#define sin             SDL_uclibc_sin
    1.72 +#else
    1.73 +#define sin             SDL_sin
    1.74 +#endif
    1.75 +
    1.76 +#ifndef HAVE_SQRT
    1.77 +#define __ieee754_sqrt  SDL_sqrt
    1.78 +#endif
    1.79  
    1.80  /* vi: set ts=4 sw=4 expandtab: */