comparison 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
comparison
equal deleted inserted replaced
3011:8f4ed5ec2b06 3012:7e30c2dc7783
18 18
19 Sam Lantinga 19 Sam Lantinga
20 slouken@libsdl.org 20 slouken@libsdl.org
21 */ 21 */
22 #include "SDL_config.h" 22 #include "SDL_config.h"
23 23 #include "SDL_stdinc.h"
24 #ifdef HAVE_MATH_H
25 #define _USE_MATH_DEFINES
26 #include <math.h>
27 #else
28 24
29 /* Math routines from uClibc: http://www.uclibc.org */ 25 /* Math routines from uClibc: http://www.uclibc.org */
30 26
31 #define M_PI 3.14159265358979323846264338327950288 /* pi */ 27 #ifdef HAVE_COPYSIGN
28 #define copysign SDL_uclibc_copysign
29 #else
30 #define copysign SDL_copysign
31 #endif
32 32
33 extern double __ieee754_log(double x); 33 #ifdef HAVE_COS
34 extern double __ieee754_pow(double x, double y); 34 #define cos SDL_uclibc_cos
35 extern double __ieee754_sqrt(double x); 35 #else
36 #define cos SDL_cos
37 #endif
36 38
37 #define log(x) __ieee754_log(x) 39 #ifdef HAVE_FABS
38 #define pow(x, y) __ieee754_pow(x, y) 40 #define fabs SDL_uclibc_fabs
39 #define sqrt(x) __ieee754_sqrt(x) 41 #else
42 #define fabs SDL_fabs
43 #endif
40 44
41 extern double copysign(double x, double y); 45 #ifdef HAVE_FLOOR
42 extern double cos(double x); 46 #define floor SDL_uclibc_floor
43 extern double fabs(double x); 47 #else
44 extern double floor(double x); 48 #define floor SDL_floor
45 extern double scalbn(double x, int n); 49 #endif
46 extern double sin(double x);
47 50
48 #define sinf(x) (float)sin((double)x) 51 #ifndef HAVE_LOG
49 #define cosf(x) (float)cos((double)x) 52 #define __ieee754_log SDL_log
53 #endif
50 54
51 #endif /* HAVE_MATH_H */ 55 #ifndef HAVE_POW
56 #define __ieee754_pow SDL_pow
57 #endif
58
59 #ifdef HAVE_SCALBN
60 #define scalbn SDL_uclibc_scalbn
61 #else
62 #define scalbn SDL_scalbn
63 #endif
64
65 #ifdef HAVE_SIN
66 #define sin SDL_uclibc_sin
67 #else
68 #define sin SDL_sin
69 #endif
70
71 #ifndef HAVE_SQRT
72 #define __ieee754_sqrt SDL_sqrt
73 #endif
52 74
53 /* vi: set ts=4 sw=4 expandtab: */ 75 /* vi: set ts=4 sw=4 expandtab: */