src/libm/math.h
author Sam Lantinga <slouken@libsdl.org>
Wed, 16 Feb 2011 17:17:21 -0800
changeset 5328 f34a5f9ce9f6
parent 5262 b530ef003506
child 5535 96594ac5fd1a
permissions -rw-r--r--
Fixed bug 1122 (spinlock fails to compile with -march=armv4t)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2756
a98604b691c8 Expanded the libm support and put it into a separate directory.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     1
/*
a98604b691c8 Expanded the libm support and put it into a separate directory.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     2
    SDL - Simple DirectMedia Layer
5262
b530ef003506 Happy 2011! :)
Sam Lantinga <slouken@libsdl.org>
parents: 4873
diff changeset
     3
    Copyright (C) 1997-2011 Sam Lantinga
2756
a98604b691c8 Expanded the libm support and put it into a separate directory.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     4
a98604b691c8 Expanded the libm support and put it into a separate directory.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     5
    This library is free software; you can redistribute it and/or
a98604b691c8 Expanded the libm support and put it into a separate directory.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     6
    modify it under the terms of the GNU Lesser General Public
a98604b691c8 Expanded the libm support and put it into a separate directory.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     7
    License as published by the Free Software Foundation; either
a98604b691c8 Expanded the libm support and put it into a separate directory.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     8
    version 2.1 of the License, or (at your option) any later version.
a98604b691c8 Expanded the libm support and put it into a separate directory.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     9
a98604b691c8 Expanded the libm support and put it into a separate directory.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    10
    This library is distributed in the hope that it will be useful,
a98604b691c8 Expanded the libm support and put it into a separate directory.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
a98604b691c8 Expanded the libm support and put it into a separate directory.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
a98604b691c8 Expanded the libm support and put it into a separate directory.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    13
    Lesser General Public License for more details.
a98604b691c8 Expanded the libm support and put it into a separate directory.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    14
a98604b691c8 Expanded the libm support and put it into a separate directory.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    15
    You should have received a copy of the GNU Lesser General Public
a98604b691c8 Expanded the libm support and put it into a separate directory.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    16
    License along with this library; if not, write to the Free Software
a98604b691c8 Expanded the libm support and put it into a separate directory.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    17
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
a98604b691c8 Expanded the libm support and put it into a separate directory.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    18
a98604b691c8 Expanded the libm support and put it into a separate directory.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    19
    Sam Lantinga
a98604b691c8 Expanded the libm support and put it into a separate directory.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    20
    slouken@libsdl.org
a98604b691c8 Expanded the libm support and put it into a separate directory.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    21
*/
a98604b691c8 Expanded the libm support and put it into a separate directory.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    22
#include "SDL_config.h"
3012
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
    23
#include "SDL_stdinc.h"
2756
a98604b691c8 Expanded the libm support and put it into a separate directory.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    24
2760
02aa80d7905f Updated Visual C++ build
Sam Lantinga <slouken@libsdl.org>
parents: 2759
diff changeset
    25
/* Math routines from uClibc: http://www.uclibc.org */
02aa80d7905f Updated Visual C++ build
Sam Lantinga <slouken@libsdl.org>
parents: 2759
diff changeset
    26
4873
67ad1c88dda0 Added atan implementation from uClibc
Sam Lantinga <slouken@libsdl.org>
parents: 4870
diff changeset
    27
#ifdef HAVE_ATAN
67ad1c88dda0 Added atan implementation from uClibc
Sam Lantinga <slouken@libsdl.org>
parents: 4870
diff changeset
    28
#define atan            SDL_uclibc_atan
67ad1c88dda0 Added atan implementation from uClibc
Sam Lantinga <slouken@libsdl.org>
parents: 4870
diff changeset
    29
#else
67ad1c88dda0 Added atan implementation from uClibc
Sam Lantinga <slouken@libsdl.org>
parents: 4870
diff changeset
    30
#define atan            SDL_atan
67ad1c88dda0 Added atan implementation from uClibc
Sam Lantinga <slouken@libsdl.org>
parents: 4870
diff changeset
    31
#endif
67ad1c88dda0 Added atan implementation from uClibc
Sam Lantinga <slouken@libsdl.org>
parents: 4870
diff changeset
    32
4870
d275c95ddc05 Added atan2 implementation from uClibc
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
    33
#ifndef HAVE_ATAN2
d275c95ddc05 Added atan2 implementation from uClibc
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
    34
#define __ieee754_atan2 SDL_atan2
d275c95ddc05 Added atan2 implementation from uClibc
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
    35
#endif
d275c95ddc05 Added atan2 implementation from uClibc
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
    36
3012
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
    37
#ifdef HAVE_COPYSIGN
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
    38
#define copysign        SDL_uclibc_copysign
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
    39
#else
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
    40
#define copysign        SDL_copysign
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
    41
#endif
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
    42
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
    43
#ifdef HAVE_COS
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
    44
#define cos             SDL_uclibc_cos
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
    45
#else
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
    46
#define cos             SDL_cos
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
    47
#endif
2769
2a46b5912665 Added missing math.h functionality for SDL_audiocvt.c
Sam Lantinga <slouken@libsdl.org>
parents: 2768
diff changeset
    48
3012
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
    49
#ifdef HAVE_FABS
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
    50
#define fabs            SDL_uclibc_fabs
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
    51
#else
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
    52
#define fabs            SDL_fabs
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
    53
#endif
2756
a98604b691c8 Expanded the libm support and put it into a separate directory.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    54
3012
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
    55
#ifdef HAVE_FLOOR
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
    56
#define floor           SDL_uclibc_floor
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
    57
#else
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
    58
#define floor           SDL_floor
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
    59
#endif
2756
a98604b691c8 Expanded the libm support and put it into a separate directory.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    60
3012
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
    61
#ifndef HAVE_LOG
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
    62
#define __ieee754_log   SDL_log
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
    63
#endif
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
    64
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
    65
#ifndef HAVE_POW
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
    66
#define __ieee754_pow   SDL_pow
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
    67
#endif
2756
a98604b691c8 Expanded the libm support and put it into a separate directory.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    68
3012
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
    69
#ifdef HAVE_SCALBN
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
    70
#define scalbn          SDL_uclibc_scalbn
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
    71
#else
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
    72
#define scalbn          SDL_scalbn
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
    73
#endif
2769
2a46b5912665 Added missing math.h functionality for SDL_audiocvt.c
Sam Lantinga <slouken@libsdl.org>
parents: 2768
diff changeset
    74
3012
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
    75
#ifdef HAVE_SIN
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
    76
#define sin             SDL_uclibc_sin
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
    77
#else
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
    78
#define sin             SDL_sin
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
    79
#endif
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
    80
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
    81
#ifndef HAVE_SQRT
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
    82
#define __ieee754_sqrt  SDL_sqrt
7e30c2dc7783 Fixed Visual C++ release build for Visual C++ 2005
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
    83
#endif
2756
a98604b691c8 Expanded the libm support and put it into a separate directory.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    84
a98604b691c8 Expanded the libm support and put it into a separate directory.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    85
/* vi: set ts=4 sw=4 expandtab: */