Hans Leidekker | 285ad72 | 2004-03-12 19:47:20 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Math functions. |
| 3 | * |
| 4 | * Derived from the mingw header written by Colin Peters. |
| 5 | * Modified for Wine use by Hans Leidekker. |
| 6 | * This file is in the public domain. |
| 7 | */ |
| 8 | |
Vincent Béron | dc7c2e4 | 2003-09-02 00:58:21 +0000 | [diff] [blame] | 9 | #ifndef __WINE_MATH_H |
| 10 | #define __WINE_MATH_H |
Alexandre Julliard | 33fa6c2 | 2008-12-11 22:37:34 +0100 | [diff] [blame] | 11 | |
| 12 | #include <crtdefs.h> |
Hans Leidekker | 285ad72 | 2004-03-12 19:47:20 +0000 | [diff] [blame] | 13 | |
Dmitry Timoshkov | 2af96fe | 2007-02-20 16:35:41 +0800 | [diff] [blame] | 14 | #include <pshpack8.h> |
| 15 | |
Vincent Béron | dc7c2e4 | 2003-09-02 00:58:21 +0000 | [diff] [blame] | 16 | #ifdef __cplusplus |
| 17 | extern "C" { |
| 18 | #endif |
| 19 | |
Hans Leidekker | 285ad72 | 2004-03-12 19:47:20 +0000 | [diff] [blame] | 20 | #define _DOMAIN 1 /* domain error in argument */ |
| 21 | #define _SING 2 /* singularity */ |
| 22 | #define _OVERFLOW 3 /* range overflow */ |
| 23 | #define _UNDERFLOW 4 /* range underflow */ |
| 24 | #define _TLOSS 5 /* total loss of precision */ |
| 25 | #define _PLOSS 6 /* partial loss of precision */ |
| 26 | |
Dimitrie O. Paun | 0377462 | 2004-06-25 01:19:15 +0000 | [diff] [blame] | 27 | #ifndef _EXCEPTION_DEFINED |
| 28 | #define _EXCEPTION_DEFINED |
| 29 | struct _exception |
Hans Leidekker | 285ad72 | 2004-03-12 19:47:20 +0000 | [diff] [blame] | 30 | { |
| 31 | int type; |
| 32 | char *name; |
| 33 | double arg1; |
| 34 | double arg2; |
| 35 | double retval; |
| 36 | }; |
Dimitrie O. Paun | 0377462 | 2004-06-25 01:19:15 +0000 | [diff] [blame] | 37 | #endif /* _EXCEPTION_DEFINED */ |
Hans Leidekker | 285ad72 | 2004-03-12 19:47:20 +0000 | [diff] [blame] | 38 | |
Dimitrie O. Paun | 0377462 | 2004-06-25 01:19:15 +0000 | [diff] [blame] | 39 | #ifndef _COMPLEX_DEFINED |
| 40 | #define _COMPLEX_DEFINED |
| 41 | struct _complex |
Hans Leidekker | 285ad72 | 2004-03-12 19:47:20 +0000 | [diff] [blame] | 42 | { |
| 43 | double x; /* Real part */ |
| 44 | double y; /* Imaginary part */ |
| 45 | }; |
Dimitrie O. Paun | 0377462 | 2004-06-25 01:19:15 +0000 | [diff] [blame] | 46 | #endif /* _COMPLEX_DEFINED */ |
Hans Leidekker | 285ad72 | 2004-03-12 19:47:20 +0000 | [diff] [blame] | 47 | |
Alexandre Julliard | bb33b0a | 2008-12-17 14:45:18 +0100 | [diff] [blame] | 48 | double __cdecl sin(double); |
| 49 | double __cdecl cos(double); |
| 50 | double __cdecl tan(double); |
| 51 | double __cdecl sinh(double); |
| 52 | double __cdecl cosh(double); |
| 53 | double __cdecl tanh(double); |
| 54 | double __cdecl asin(double); |
| 55 | double __cdecl acos(double); |
| 56 | double __cdecl atan(double); |
| 57 | double __cdecl atan2(double, double); |
| 58 | double __cdecl exp(double); |
| 59 | double __cdecl log(double); |
| 60 | double __cdecl log10(double); |
| 61 | double __cdecl pow(double, double); |
| 62 | double __cdecl sqrt(double); |
| 63 | double __cdecl ceil(double); |
| 64 | double __cdecl floor(double); |
| 65 | double __cdecl fabs(double); |
| 66 | double __cdecl ldexp(double, int); |
| 67 | double __cdecl frexp(double, int*); |
| 68 | double __cdecl modf(double, double*); |
| 69 | double __cdecl fmod(double, double); |
Hans Leidekker | 285ad72 | 2004-03-12 19:47:20 +0000 | [diff] [blame] | 70 | |
Alexandre Julliard | bb33b0a | 2008-12-17 14:45:18 +0100 | [diff] [blame] | 71 | double __cdecl hypot(double, double); |
| 72 | double __cdecl j0(double); |
| 73 | double __cdecl j1(double); |
| 74 | double __cdecl jn(int, double); |
| 75 | double __cdecl y0(double); |
| 76 | double __cdecl y1(double); |
| 77 | double __cdecl yn(int, double); |
Hans Leidekker | 285ad72 | 2004-03-12 19:47:20 +0000 | [diff] [blame] | 78 | |
Maarten Lankhorst | f4fcd81 | 2010-05-01 16:32:45 +0200 | [diff] [blame] | 79 | #ifdef __x86_64__ |
| 80 | |
| 81 | float __cdecl sinf(float); |
| 82 | float __cdecl cosf(float); |
| 83 | float __cdecl tanf(float); |
| 84 | float __cdecl sinhf(float); |
| 85 | float __cdecl coshf(float); |
| 86 | float __cdecl tanhf(float); |
| 87 | float __cdecl asinf(float); |
| 88 | float __cdecl acosf(float); |
| 89 | float __cdecl atanf(float); |
| 90 | float __cdecl atan2f(float, float); |
| 91 | float __cdecl expf(float); |
| 92 | float __cdecl logf(float); |
| 93 | float __cdecl log10f(float); |
| 94 | float __cdecl powf(float, float); |
| 95 | float __cdecl sqrtf(float); |
| 96 | float __cdecl ceilf(float); |
| 97 | float __cdecl floorf(float); |
| 98 | float __cdecl fabsf(float); |
| 99 | float __cdecl ldexpf(float, int); |
| 100 | float __cdecl frexpf(float, int*); |
| 101 | float __cdecl modff(float, float*); |
| 102 | float __cdecl fmodf(float, float); |
| 103 | |
| 104 | #else |
| 105 | |
| 106 | #define sinf(x) ((float)sin((double)(x))) |
| 107 | #define cosf(x) ((float)cos((double)(x))) |
| 108 | #define tanf(x) ((float)tan((double)(x))) |
| 109 | #define sinhf(x) ((float)sinh((double)(x))) |
| 110 | #define coshf(x) ((float)cosh((double)(x))) |
| 111 | #define tanhf(x) ((float)tanh((double)(x))) |
| 112 | #define asinf(x) ((float)asin((double)(x))) |
| 113 | #define acosf(x) ((float)acos((double)(x))) |
| 114 | #define atanf(x) ((float)atan((double)(x))) |
| 115 | #define atan2f(x,y) ((float)atan2((double)(x), (double)(y))) |
| 116 | #define expf(x) ((float)exp((double)(x))) |
| 117 | #define logf(x) ((float)log((double)(x))) |
| 118 | #define log10f(x) ((float)log10((double)(x))) |
| 119 | #define powf(x,y) ((float)pow((double)(x), (double)(y))) |
| 120 | #define sqrtf(x) ((float)sqrt((double)(x))) |
| 121 | #define ceilf(x) ((float)ceil((double)(x))) |
| 122 | #define floorf(x) ((float)floor((double)(x))) |
| 123 | #define frexpf(x) ((float)frexp((double)(x))) |
| 124 | #define modff(x,y) ((float)modf((double)(x), (double*)(y))) |
| 125 | #define fmodf(x,y) ((float)fmod((double)(x), (double)(y))) |
| 126 | |
| 127 | #endif |
| 128 | |
| 129 | #define fabsf(x) ((float)fabs((double)(x))) |
| 130 | #define ldexpf(x) ((float)ldexp((double)(x))) |
| 131 | |
| 132 | float __cdecl hypotf(float, float); |
| 133 | |
Alexandre Julliard | bb33b0a | 2008-12-17 14:45:18 +0100 | [diff] [blame] | 134 | int __cdecl _matherr(struct _exception*); |
| 135 | double __cdecl _cabs(struct _complex); |
Hans Leidekker | 285ad72 | 2004-03-12 19:47:20 +0000 | [diff] [blame] | 136 | |
Dimitrie O. Paun | a5686fe | 2004-04-09 19:02:45 +0000 | [diff] [blame] | 137 | #ifndef HUGE_VAL |
| 138 | # if defined(__GNUC__) && (__GNUC__ >= 3) |
| 139 | # define HUGE_VAL (__extension__ 0x1.0p2047) |
| 140 | # else |
| 141 | static const union { |
| 142 | unsigned char __c[8]; |
| 143 | double __d; |
| 144 | } __huge_val = { { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f } }; |
| 145 | # define HUGE_VAL (__huge_val.__d) |
| 146 | # endif |
| 147 | #endif |
| 148 | |
Vincent Béron | dc7c2e4 | 2003-09-02 00:58:21 +0000 | [diff] [blame] | 149 | #ifdef __cplusplus |
| 150 | } |
| 151 | #endif |
| 152 | |
Dmitry Timoshkov | 2af96fe | 2007-02-20 16:35:41 +0800 | [diff] [blame] | 153 | #include <poppack.h> |
| 154 | |
Vincent Béron | dc7c2e4 | 2003-09-02 00:58:21 +0000 | [diff] [blame] | 155 | #endif /* __WINE_MATH_H */ |