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.

425 lines
12 KiB

  1. /***
  2. *math.h - definitions and declarations for math library
  3. *
  4. * Copyright (c) 1985-1995, 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. * [Public]
  12. *
  13. ****/
  14. #ifndef _INC_MATH
  15. #define _INC_MATH
  16. #if !defined(_WIN32) && !defined(_MAC)
  17. #error ERROR: Only Mac or Win32 targets supported!
  18. #endif
  19. #ifdef _MSC_VER
  20. /*
  21. * Currently, all MS C compilers for Win32 platforms default to 8 byte
  22. * alignment.
  23. */
  24. #pragma pack(push,8)
  25. #endif /* _MSC_VER */
  26. #ifdef __cplusplus
  27. extern "C" {
  28. #endif
  29. #ifndef __assembler /* Protect from assembler */
  30. /* Define _CRTAPI1 (for compatibility with the NT SDK) */
  31. #ifndef _CRTAPI1
  32. #if _MSC_VER >= 800 && _M_IX86 >= 300
  33. #define _CRTAPI1 __cdecl
  34. #else
  35. #define _CRTAPI1
  36. #endif
  37. #endif
  38. /* Define _CRTAPI2 (for compatibility with the NT SDK) */
  39. #ifndef _CRTAPI2
  40. #if _MSC_VER >= 800 && _M_IX86 >= 300
  41. #define _CRTAPI2 __cdecl
  42. #else
  43. #define _CRTAPI2
  44. #endif
  45. #endif
  46. /* Define _CRTIMP */
  47. #ifndef _CRTIMP
  48. #ifdef _NTSDK
  49. /* definition compatible with NT SDK */
  50. #define _CRTIMP
  51. #else /* ndef _NTSDK */
  52. /* current definition */
  53. #ifdef _DLL
  54. #define _CRTIMP __declspec(dllimport)
  55. #else /* ndef _DLL */
  56. #define _CRTIMP
  57. #endif /* _DLL */
  58. #endif /* _NTSDK */
  59. #endif /* _CRTIMP */
  60. /* Define __cdecl for non-Microsoft compilers */
  61. #if ( !defined(_MSC_VER) && !defined(__cdecl) )
  62. #define __cdecl
  63. #endif
  64. /* Definition of _exception struct - this struct is passed to the matherr
  65. * routine when a floating point exception is detected
  66. */
  67. #ifndef _EXCEPTION_DEFINED
  68. struct _exception {
  69. int type; /* exception type - see below */
  70. char *name; /* name of function where error occured */
  71. double arg1; /* first argument to function */
  72. double arg2; /* second argument (if any) to function */
  73. double retval; /* value to be returned by function */
  74. } ;
  75. #define _EXCEPTION_DEFINED
  76. #endif
  77. /* Definition of a _complex struct to be used by those who use cabs and
  78. * want type checking on their argument
  79. */
  80. #ifndef _COMPLEX_DEFINED
  81. struct _complex {
  82. double x,y; /* real and imaginary parts */
  83. } ;
  84. #if !__STDC__
  85. /* Non-ANSI name for compatibility */
  86. #define complex _complex
  87. #endif
  88. #define _COMPLEX_DEFINED
  89. #endif
  90. #endif /* __assembler */
  91. /* Constant definitions for the exception type passed in the _exception struct
  92. */
  93. #define _DOMAIN 1 /* argument domain error */
  94. #define _SING 2 /* argument singularity */
  95. #define _OVERFLOW 3 /* overflow range error */
  96. #define _UNDERFLOW 4 /* underflow range error */
  97. #define _TLOSS 5 /* total loss of precision */
  98. #define _PLOSS 6 /* partial loss of precision */
  99. #define EDOM 33
  100. #define ERANGE 34
  101. /* Definitions of _HUGE and HUGE_VAL - respectively the XENIX and ANSI names
  102. * for a value returned in case of error by a number of the floating point
  103. * math routines
  104. */
  105. #ifndef __assembler /* Protect from assembler */
  106. #ifdef _NTSDK
  107. /* definition compatible with NT SDK */
  108. #ifdef _DLL
  109. #define _HUGE (*_HUGE_dll)
  110. extern double * _HUGE_dll;
  111. #else /* ndef _DLL */
  112. extern double _HUGE;
  113. #endif /* _DLL */
  114. #else /* ndef _NTSDK */
  115. /* current definition */
  116. _CRTIMP extern double _HUGE;
  117. #endif /* _NTSDK */
  118. #endif /* __assembler */
  119. #define HUGE_VAL _HUGE
  120. /* Function prototypes */
  121. #if !defined(__assembler) /* Protect from assembler */
  122. #if _M_MRX000
  123. _CRTIMP int __cdecl abs(int);
  124. _CRTIMP double __cdecl acos(double);
  125. _CRTIMP double __cdecl asin(double);
  126. _CRTIMP double __cdecl atan(double);
  127. _CRTIMP double __cdecl atan2(double, double);
  128. _CRTIMP double __cdecl cos(double);
  129. _CRTIMP double __cdecl cosh(double);
  130. _CRTIMP double __cdecl exp(double);
  131. _CRTIMP double __cdecl fabs(double);
  132. _CRTIMP double __cdecl fmod(double, double);
  133. _CRTIMP long __cdecl labs(long);
  134. _CRTIMP double __cdecl log(double);
  135. _CRTIMP double __cdecl log10(double);
  136. _CRTIMP double __cdecl pow(double, double);
  137. _CRTIMP double __cdecl sin(double);
  138. _CRTIMP double __cdecl sinh(double);
  139. _CRTIMP double __cdecl tan(double);
  140. _CRTIMP double __cdecl tanh(double);
  141. _CRTIMP double __cdecl sqrt(double);
  142. #else
  143. int __cdecl abs(int);
  144. double __cdecl acos(double);
  145. double __cdecl asin(double);
  146. double __cdecl atan(double);
  147. double __cdecl atan2(double, double);
  148. double __cdecl cos(double);
  149. double __cdecl cosh(double);
  150. double __cdecl exp(double);
  151. double __cdecl fabs(double);
  152. double __cdecl fmod(double, double);
  153. long __cdecl labs(long);
  154. double __cdecl log(double);
  155. double __cdecl log10(double);
  156. double __cdecl pow(double, double);
  157. double __cdecl sin(double);
  158. double __cdecl sinh(double);
  159. double __cdecl tan(double);
  160. double __cdecl tanh(double);
  161. double __cdecl sqrt(double);
  162. #endif
  163. _CRTIMP double __cdecl atof(const char *);
  164. _CRTIMP double __cdecl _cabs(struct _complex);
  165. _CRTIMP double __cdecl ceil(double);
  166. _CRTIMP double __cdecl floor(double);
  167. _CRTIMP double __cdecl frexp(double, int *);
  168. _CRTIMP double __cdecl _hypot(double, double);
  169. _CRTIMP double __cdecl _j0(double);
  170. _CRTIMP double __cdecl _j1(double);
  171. _CRTIMP double __cdecl _jn(int, double);
  172. _CRTIMP double __cdecl ldexp(double, int);
  173. int __cdecl _matherr(struct _exception *);
  174. _CRTIMP double __cdecl modf(double, double *);
  175. _CRTIMP double __cdecl _y0(double);
  176. _CRTIMP double __cdecl _y1(double);
  177. _CRTIMP double __cdecl _yn(int, double);
  178. #ifdef _M_MRX000
  179. /* MIPS fast prototypes for float */
  180. /* ANSI C, 4.5 Mathematics */
  181. /* 4.5.2 Trigonometric functions */
  182. _CRTIMP float __cdecl acosf( float );
  183. _CRTIMP float __cdecl asinf( float );
  184. _CRTIMP float __cdecl atanf( float );
  185. _CRTIMP float __cdecl atan2f( float , float );
  186. _CRTIMP float __cdecl cosf( float );
  187. _CRTIMP float __cdecl sinf( float );
  188. _CRTIMP float __cdecl tanf( float );
  189. /* 4.5.3 Hyperbolic functions */
  190. _CRTIMP float __cdecl coshf( float );
  191. _CRTIMP float __cdecl sinhf( float );
  192. _CRTIMP float __cdecl tanhf( float );
  193. /* 4.5.4 Exponential and logarithmic functions */
  194. _CRTIMP float __cdecl expf( float );
  195. _CRTIMP float __cdecl logf( float );
  196. _CRTIMP float __cdecl log10f( float );
  197. _CRTIMP float __cdecl modff( float , float* );
  198. /* 4.5.5 Power functions */
  199. _CRTIMP float __cdecl powf( float , float );
  200. float __cdecl sqrtf( float );
  201. /* 4.5.6 Nearest integer, absolute value, and remainder functions */
  202. float __cdecl ceilf( float );
  203. float __cdecl fabsf( float );
  204. float __cdecl floorf( float );
  205. _CRTIMP float __cdecl fmodf( float , float );
  206. _CRTIMP float __cdecl hypotf(float, float);
  207. #endif /* _M_MRX000 */
  208. #if !defined(_M_M68K)
  209. /* Macros defining long double functions to be their double counterparts
  210. * (long double is synonymous with double in this implementation).
  211. */
  212. #define acosl(x) ((long double)acos((double)(x)))
  213. #define asinl(x) ((long double)asin((double)(x)))
  214. #define atanl(x) ((long double)atan((double)(x)))
  215. #define atan2l(x,y) ((long double)atan2((double)(x), (double)(y)))
  216. #define _cabsl _cabs
  217. #define ceill(x) ((long double)ceil((double)(x)))
  218. #define cosl(x) ((long double)cos((double)(x)))
  219. #define coshl(x) ((long double)cosh((double)(x)))
  220. #define expl(x) ((long double)exp((double)(x)))
  221. #define fabsl(x) ((long double)fabs((double)(x)))
  222. #define floorl(x) ((long double)floor((double)(x)))
  223. #define fmodl(x,y) ((long double)fmod((double)(x), (double)(y)))
  224. #define frexpl(x,y) ((long double)frexp((double)(x), (y)))
  225. #define _hypotl(x,y) ((long double)_hypot((double)(x), (double)(y)))
  226. #define ldexpl(x,y) ((long double)ldexp((double)(x), (y)))
  227. #define logl(x) ((long double)log((double)(x)))
  228. #define log10l(x) ((long double)log10((double)(x)))
  229. #define _matherrl _matherr
  230. #define modfl(x,y) ((long double)modf((double)(x), (double *)(y)))
  231. #define powl(x,y) ((long double)pow((double)(x), (double)(y)))
  232. #define sinl(x) ((long double)sin((double)(x)))
  233. #define sinhl(x) ((long double)sinh((double)(x)))
  234. #define sqrtl(x) ((long double)sqrt((double)(x)))
  235. #define tanl(x) ((long double)tan((double)(x)))
  236. #define tanhl(x) ((long double)tanh((double)(x)))
  237. #endif /* _M_M68K */
  238. #endif /* __assembler */
  239. #if !__STDC__
  240. /* Non-ANSI names for compatibility */
  241. #define DOMAIN _DOMAIN
  242. #define SING _SING
  243. #define OVERFLOW _OVERFLOW
  244. #define UNDERFLOW _UNDERFLOW
  245. #define TLOSS _TLOSS
  246. #define PLOSS _PLOSS
  247. #if !defined(_M_MPPC) && !defined(_M_M68K)
  248. #define matherr _matherr
  249. #endif /* !defined(_M_MPPC) && !defined(_M_M68K) */
  250. #ifndef __assembler /* Protect from assembler */
  251. #ifdef _NTSDK
  252. /* Definitions and declarations compatible with NT SDK */
  253. #ifdef _DLL
  254. #define HUGE (*HUGE_dll)
  255. extern double * HUGE_dll;
  256. #else /* ndef _DLL */
  257. extern double HUGE;
  258. #endif /* _DLL */
  259. #define cabs _cabs
  260. #define hypot _hypot
  261. #define j0 _j0
  262. #define j1 _j1
  263. #define jn _jn
  264. #define y0 _y0
  265. #define y1 _y1
  266. #define yn _yn
  267. #else /* ndef _NTSDK */
  268. /* Current definitions and declarations */
  269. _CRTIMP extern double HUGE;
  270. _CRTIMP double __cdecl cabs(struct complex);
  271. _CRTIMP double __cdecl hypot(double, double);
  272. _CRTIMP double __cdecl j0(double);
  273. _CRTIMP double __cdecl j1(double);
  274. _CRTIMP double __cdecl jn(int, double);
  275. int __cdecl matherr(struct _exception *);
  276. _CRTIMP double __cdecl y0(double);
  277. _CRTIMP double __cdecl y1(double);
  278. _CRTIMP double __cdecl yn(int, double);
  279. #endif /* _NTSDK */
  280. #endif /* __assembler */
  281. #endif /* __STDC__ */
  282. #ifdef _M_M68K
  283. /* definition of _exceptionl struct - this struct is passed to the _matherrl
  284. * routine when a floating point exception is detected in a long double routine
  285. */
  286. #ifndef _LD_EXCEPTION_DEFINED
  287. struct _exceptionl {
  288. int type; /* exception type - see below */
  289. char *name; /* name of function where error occured */
  290. long double arg1; /* first argument to function */
  291. long double arg2; /* second argument (if any) to function */
  292. long double retval; /* value to be returned by function */
  293. } ;
  294. #define _LD_EXCEPTION_DEFINED
  295. #endif
  296. /* definition of a _complexl struct to be used by those who use _cabsl and
  297. * want type checking on their argument
  298. */
  299. #ifndef _LD_COMPLEX_DEFINED
  300. struct _complexl {
  301. long double x,y; /* real and imaginary parts */
  302. } ;
  303. #define _LD_COMPLEX_DEFINED
  304. #endif
  305. long double __cdecl acosl(long double);
  306. long double __cdecl asinl(long double);
  307. long double __cdecl atanl(long double);
  308. long double __cdecl atan2l(long double, long double);
  309. long double __cdecl _atold(const char *);
  310. long double __cdecl _cabsl(struct _complexl);
  311. long double __cdecl ceill(long double);
  312. long double __cdecl cosl(long double);
  313. long double __cdecl coshl(long double);
  314. long double __cdecl expl(long double);
  315. long double __cdecl fabsl(long double);
  316. long double __cdecl floorl(long double);
  317. long double __cdecl fmodl(long double, long double);
  318. long double __cdecl frexpl(long double, int *);
  319. long double __cdecl _hypotl(long double, long double);
  320. long double __cdecl _j0l(long double);
  321. long double __cdecl _j1l(long double);
  322. long double __cdecl _jnl(int, long double);
  323. long double __cdecl ldexpl(long double, int);
  324. long double __cdecl logl(long double);
  325. long double __cdecl log10l(long double);
  326. int __cdecl _matherrl(struct _exceptionl *);
  327. long double __cdecl modfl(long double, long double *);
  328. long double __cdecl powl(long double, long double);
  329. long double __cdecl sinl(long double);
  330. long double __cdecl sinhl(long double);
  331. long double __cdecl sqrtl(long double);
  332. long double __cdecl tanl(long double);
  333. long double __cdecl tanhl(long double);
  334. long double __cdecl _y0l(long double);
  335. long double __cdecl _y1l(long double);
  336. long double __cdecl _ynl(int, long double);
  337. #endif /* _M_M68K */
  338. #ifdef __cplusplus
  339. }
  340. #endif
  341. #ifdef _MSC_VER
  342. #pragma pack(pop)
  343. #endif /* _MSC_VER */
  344. #endif /* _INC_MATH */