Mercurial > sdl-ios-xcode
diff src/libm/math.h @ 3012:7e30c2dc7783
Fixed Visual C++ release build for Visual C++ 2005
* Some math functions become intrinsic in release mode, so we need to
convert all the math functions into SDL math functions, like we did
with the stdlib functions.
* Constant initializers of 8-bit values become calls to memset() in
release mode, but memset() itself is an intrinsic when explicitly
called. So we'll just explicitly call memset() in those cases.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sat, 10 Jan 2009 18:32:24 +0000 |
parents | 99210400e8b9 |
children | f7b03b6838cb |
line wrap: on
line diff
--- a/src/libm/math.h Fri Jan 09 20:43:30 2009 +0000 +++ b/src/libm/math.h Sat Jan 10 18:32:24 2009 +0000 @@ -20,34 +20,56 @@ slouken@libsdl.org */ #include "SDL_config.h" - -#ifdef HAVE_MATH_H -#define _USE_MATH_DEFINES -#include <math.h> -#else +#include "SDL_stdinc.h" /* Math routines from uClibc: http://www.uclibc.org */ -#define M_PI 3.14159265358979323846264338327950288 /* pi */ +#ifdef HAVE_COPYSIGN +#define copysign SDL_uclibc_copysign +#else +#define copysign SDL_copysign +#endif + +#ifdef HAVE_COS +#define cos SDL_uclibc_cos +#else +#define cos SDL_cos +#endif -extern double __ieee754_log(double x); -extern double __ieee754_pow(double x, double y); -extern double __ieee754_sqrt(double x); +#ifdef HAVE_FABS +#define fabs SDL_uclibc_fabs +#else +#define fabs SDL_fabs +#endif -#define log(x) __ieee754_log(x) -#define pow(x, y) __ieee754_pow(x, y) -#define sqrt(x) __ieee754_sqrt(x) +#ifdef HAVE_FLOOR +#define floor SDL_uclibc_floor +#else +#define floor SDL_floor +#endif -extern double copysign(double x, double y); -extern double cos(double x); -extern double fabs(double x); -extern double floor(double x); -extern double scalbn(double x, int n); -extern double sin(double x); +#ifndef HAVE_LOG +#define __ieee754_log SDL_log +#endif + +#ifndef HAVE_POW +#define __ieee754_pow SDL_pow +#endif -#define sinf(x) (float)sin((double)x) -#define cosf(x) (float)cos((double)x) +#ifdef HAVE_SCALBN +#define scalbn SDL_uclibc_scalbn +#else +#define scalbn SDL_scalbn +#endif -#endif /* HAVE_MATH_H */ +#ifdef HAVE_SIN +#define sin SDL_uclibc_sin +#else +#define sin SDL_sin +#endif + +#ifndef HAVE_SQRT +#define __ieee754_sqrt SDL_sqrt +#endif /* vi: set ts=4 sw=4 expandtab: */