Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

306 lines
7.6 KiB

  1. /***
  2. *math.h - definitions and declarations for math library
  3. *
  4. * Copyright (c) 1985-1994, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * This file contains constant definitions and external subroutine
  8. * declarations for the math subroutine library.
  9. * [ANSI/System V]
  10. *
  11. ****/
  12. #ifndef _INC_MATH
  13. #define _INC_MATH
  14. #ifdef __cplusplus
  15. extern "C" {
  16. #endif
  17. /* Define _CRTAPI1 (for compatibility with the NT SDK) */
  18. #ifndef _CRTAPI1
  19. #if ( (_MSC_VER >= 800) && (_M_IX86 >= 300) )
  20. #define _CRTAPI1 __cdecl
  21. #else
  22. #define _CRTAPI1
  23. #endif
  24. #endif
  25. /* Define _CRTAPI2 (for compatibility with the NT SDK) */
  26. #ifndef _CRTAPI2
  27. #if ( (_MSC_VER >= 800) && (_M_IX86 >= 300) )
  28. #define _CRTAPI2 __cdecl
  29. #else
  30. #define _CRTAPI2
  31. #endif
  32. #endif
  33. /* Define _CRTIMP */
  34. #ifndef _CRTIMP
  35. #ifdef _NTSDK
  36. /* definition compatible with NT SDK */
  37. #define _CRTIMP
  38. #else /* ndef _NTSDK */
  39. /* current definition */
  40. #ifdef _DLL
  41. #define _CRTIMP __declspec(dllimport)
  42. #else /* ndef _DLL */
  43. #define _CRTIMP
  44. #endif /* _DLL */
  45. #endif /* _NTSDK */
  46. #endif /* _CRTIMP */
  47. /* Define __cdecl for non-Microsoft compilers */
  48. #if ( !defined(_MSC_VER) && !defined(__cdecl) )
  49. #define __cdecl
  50. #endif
  51. /* Definition of _exception struct - this struct is passed to the matherr
  52. * routine when a floating point exception is detected
  53. */
  54. #ifndef _EXCEPTION_DEFINED
  55. struct _exception {
  56. int type; /* exception type - see below */
  57. char *name; /* name of function where error occured */
  58. double arg1; /* first argument to function */
  59. double arg2; /* second argument (if any) to function */
  60. double retval; /* value to be returned by function */
  61. } ;
  62. #if !__STDC__
  63. /* Non-ANSI name for compatibility */
  64. #define exception _exception
  65. #endif
  66. #define _EXCEPTION_DEFINED
  67. #endif
  68. /* Definition of a _complex struct to be used by those who use cabs and
  69. * want type checking on their argument
  70. */
  71. #ifndef _COMPLEX_DEFINED
  72. struct _complex {
  73. double x,y; /* real and imaginary parts */
  74. } ;
  75. #if !__STDC__
  76. /* Non-ANSI name for compatibility */
  77. #define complex _complex
  78. #endif
  79. #define _COMPLEX_DEFINED
  80. #endif
  81. /* Constant definitions for the exception type passed in the _exception struct
  82. */
  83. #define _DOMAIN 1 /* argument domain error */
  84. #define _SING 2 /* argument singularity */
  85. #define _OVERFLOW 3 /* overflow range error */
  86. #define _UNDERFLOW 4 /* underflow range error */
  87. #define _TLOSS 5 /* total loss of precision */
  88. #define _PLOSS 6 /* partial loss of precision */
  89. #define EDOM 33
  90. #define ERANGE 34
  91. /* Definitions of _HUGE and HUGE_VAL - respectively the XENIX and ANSI names
  92. * for a value returned in case of error by a number of the floating point
  93. * math routines
  94. */
  95. #ifdef _NTSDK
  96. /* definition compatible with NT SDK */
  97. #ifdef _DLL
  98. #define _HUGE (*_HUGE_dll)
  99. extern double * _HUGE_dll;
  100. #else /* ndef _DLL */
  101. extern double _HUGE;
  102. #endif /* _DLL */
  103. #else /* ndef _NTSDK */
  104. /* current definition */
  105. _CRTIMP extern double _HUGE;
  106. #endif /* _NTSDK */
  107. #define HUGE_VAL _HUGE
  108. /* Function prototypes */
  109. int __cdecl abs(int);
  110. double __cdecl acos(double);
  111. double __cdecl asin(double);
  112. double __cdecl atan(double);
  113. double __cdecl atan2(double, double);
  114. _CRTIMP double __cdecl atof(const char *);
  115. _CRTIMP double __cdecl _cabs(struct _complex);
  116. _CRTIMP double __cdecl ceil(double);
  117. double __cdecl cos(double);
  118. double __cdecl cosh(double);
  119. double __cdecl exp(double);
  120. double __cdecl fabs(double);
  121. _CRTIMP double __cdecl floor(double);
  122. double __cdecl fmod(double, double);
  123. _CRTIMP double __cdecl frexp(double, int *);
  124. _CRTIMP double __cdecl _hypot(double, double);
  125. _CRTIMP double __cdecl _j0(double);
  126. _CRTIMP double __cdecl _j1(double);
  127. _CRTIMP double __cdecl _jn(int, double);
  128. long __cdecl labs(long);
  129. _CRTIMP double __cdecl ldexp(double, int);
  130. double __cdecl log(double);
  131. double __cdecl log10(double);
  132. _CRTIMP int __cdecl _matherr(struct _exception *);
  133. _CRTIMP double __cdecl modf(double, double *);
  134. double __cdecl pow(double, double);
  135. double __cdecl sin(double);
  136. double __cdecl sinh(double);
  137. double __cdecl sqrt(double);
  138. double __cdecl tan(double);
  139. double __cdecl tanh(double);
  140. _CRTIMP double __cdecl _y0(double);
  141. _CRTIMP double __cdecl _y1(double);
  142. _CRTIMP double __cdecl _yn(int, double);
  143. #ifdef _M_MRX000
  144. /* MIPS fast prototypes for float */
  145. /* ANSI C, 4.5 Mathematics */
  146. /* 4.5.2 Trigonometric functions */
  147. float __cdecl acosf( float );
  148. float __cdecl asinf( float );
  149. float __cdecl atanf( float );
  150. float __cdecl atan2f( float , float );
  151. float __cdecl cosf( float );
  152. float __cdecl sinf( float );
  153. float __cdecl tanf( float );
  154. /* 4.5.3 Hyperbolic functions */
  155. float __cdecl coshf( float );
  156. float __cdecl sinhf( float );
  157. float __cdecl tanhf( float );
  158. /* 4.5.4 Exponential and logarithmic functions */
  159. float __cdecl expf( float );
  160. float __cdecl logf( float );
  161. float __cdecl log10f( float );
  162. float __cdecl modff( float , float* );
  163. /* 4.5.5 Power functions */
  164. float __cdecl powf( float , float );
  165. float __cdecl sqrtf( float );
  166. /* 4.5.6 Nearest integer, absolute value, and remainder functions */
  167. float __cdecl ceilf( float );
  168. float __cdecl fabsf( float );
  169. float __cdecl floorf( float );
  170. float __cdecl fmodf( float , float );
  171. #endif /* _M_MRX000 */
  172. /* Macros defining long double functions to be their double counterparts
  173. * (long double is synonymous with double in this implementation).
  174. */
  175. #define acosl(x) ((long double)acos((double)(x)))
  176. #define asinl(x) ((long double)asin((double)(x)))
  177. #define atanl(x) ((long double)atan((double)(x)))
  178. #define atan2l(x,y) ((long double)atan2((double)(x), (double)(y)))
  179. #define _cabsl _cabs
  180. #define ceill(x) ((long double)ceil((double)(x)))
  181. #define cosl(x) ((long double)cos((double)(x)))
  182. #define coshl(x) ((long double)cosh((double)(x)))
  183. #define expl(x) ((long double)exp((double)(x)))
  184. #define fabsl(x) ((long double)fabs((double)(x)))
  185. #define floorl(x) ((long double)floor((double)(x)))
  186. #define fmodl(x,y) ((long double)fmod((double)(x), (double)(y)))
  187. #define frexpl(x,y) ((long double)frexp((double)(x), (y)))
  188. #define _hypotl(x,y) ((long double)_hypot((double)(x), (double)(y)))
  189. #define ldexpl(x,y) ((long double)ldexp((double)(x), (y)))
  190. #define logl(x) ((long double)log((double)(x)))
  191. #define log10l(x) ((long double)log10((double)(x)))
  192. #define _matherrl _matherr
  193. #define modfl(x,y) ((long double)modf((double)(x), (double *)(y)))
  194. #define powl(x,y) ((long double)pow((double)(x), (double)(y)))
  195. #define sinl(x) ((long double)sin((double)(x)))
  196. #define sinhl(x) ((long double)sinh((double)(x)))
  197. #define sqrtl(x) ((long double)sqrt((double)(x)))
  198. #define tanl(x) ((long double)tan((double)(x)))
  199. #define tanhl(x) ((long double)tanh((double)(x)))
  200. #if !__STDC__
  201. /* Non-ANSI names for compatibility */
  202. #define DOMAIN _DOMAIN
  203. #define SING _SING
  204. #define OVERFLOW _OVERFLOW
  205. #define UNDERFLOW _UNDERFLOW
  206. #define TLOSS _TLOSS
  207. #define PLOSS _PLOSS
  208. #define matherr _matherr
  209. #ifdef _NTSDK
  210. /* Definitions and declarations compatible with NT SDK */
  211. #ifdef _DLL
  212. #define HUGE (*HUGE_dll)
  213. extern double * HUGE_dll;
  214. #else /* ndef _DLL */
  215. extern double HUGE;
  216. #endif /* _DLL */
  217. #define cabs _cabs
  218. #define hypot _hypot
  219. #define j0 _j0
  220. #define j1 _j1
  221. #define jn _jn
  222. #define matherr _matherr
  223. #define y0 _y0
  224. #define y1 _y1
  225. #define yn _yn
  226. #else /* ndef _NTSDK */
  227. /* Current definitions and declarations */
  228. _CRTIMP extern double HUGE;
  229. _CRTIMP double __cdecl cabs(struct complex);
  230. _CRTIMP double __cdecl hypot(double, double);
  231. _CRTIMP double __cdecl j0(double);
  232. _CRTIMP double __cdecl j1(double);
  233. _CRTIMP double __cdecl jn(int, double);
  234. _CRTIMP int __cdecl matherr(struct _exception *);
  235. _CRTIMP double __cdecl y0(double);
  236. _CRTIMP double __cdecl y1(double);
  237. _CRTIMP double __cdecl yn(int, double);
  238. #endif /* _NTSDK */
  239. #endif /* __STDC__ */
  240. #ifdef __cplusplus
  241. }
  242. #endif
  243. #endif /* _INC_MATH */