home *** CD-ROM | disk | FTP | other *** search
/ PC Format (South-Africa) 2001 June / PCFJune.iso / Xenon / C++ / FreeCommandLineTools.exe / Include / fastmath.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-01-31  |  5.7 KB  |  209 lines

  1. /*
  2.    fastmath.h - header file for the FastMath routines.  These are high
  3.                 performance math routines that don't bother checking for
  4.                 most error conditions and never call matherr.  They are
  5.                 coded for maximum speed and most are written in assembly.
  6.  
  7.                 These functions are never exported from the RTLDLL, which
  8.                 means that they always get linked directly into the PE file
  9.                 which is being created.
  10.  
  11. */
  12.  
  13. /*
  14.  *      C/C++ Run Time Library - Version 10.0
  15.  *
  16.  *      Copyright (c) 1999, 2000 by Inprise Corporation
  17.  *      All Rights Reserved.
  18.  *
  19.  */
  20.  
  21. /* $Revision:   9.4  $ */
  22.  
  23. #ifndef __FASTMATH_H
  24. #define __FASTMATH_H
  25.  
  26. #include <_defs.h>
  27. #include <math.h>
  28.  
  29. #ifdef __cplusplus
  30. extern "C" {
  31. #endif
  32.  
  33. #define _FMAPI _RTLENTRY /* FastMath API */
  34.  
  35. /* _FMAPI functions are never exported from the RTLDLL, they always get linked
  36.    into the PE file directly.
  37. */
  38.  
  39. /* double routines: */
  40.  
  41. double      _FMAPI _fm_acos    (double __x);
  42. double      _FMAPI _fm_asin    (double __x);
  43. double      _FMAPI _fm_atan    (double __x);
  44. double      _FMAPI _fm_atan2   (double __y, double __x);
  45. double      _FMAPI _fm_cos     (double __x);
  46. double      _FMAPI _fm_cosh    (double __x);
  47. double      _FMAPI _fm_exp     (double __x);
  48. double      _FMAPI _fm_fabs    (double __x);
  49. double      _FMAPI _fm_frexp   (double __x, int * __exponent);
  50. double      _FMAPI _fm_hypot   (double __x, double __y);
  51. double      _FMAPI _fm_ldexp   (double __x, int __exponent);
  52. double      _FMAPI _fm_log     (double __x);
  53. double      _FMAPI _fm_log10   (double __x);
  54. double      _FMAPI _fm_sin     (double __x);
  55. double      _FMAPI _fm_sinh    (double __x);
  56. double      _FMAPI _fm_sqrt    (double __x);
  57. double      _FMAPI _fm_tan     (double __x);
  58. double      _FMAPI _fm_tanh    (double __x);
  59.  
  60. /* long double routines: */
  61.  
  62. long double _FMAPI _fm_acosl  (long double __x);
  63. long double _FMAPI _fm_asinl  (long double __x);
  64. long double _FMAPI _fm_atan2l (long double __x, long double __y);
  65. long double _FMAPI _fm_atanl  (long double __x);
  66. long double _FMAPI _fm_coshl  (long double __x);
  67. long double _FMAPI _fm_cosl   (long double __x);
  68. long double _FMAPI _fm_expl   (long double __x);
  69. long double _FMAPI _fm_fabsl  (long double __x);
  70. long double _FMAPI _fm_frexpl (long double __x, int * __exponent);
  71. long double _FMAPI _fm_hypotl (long double __x, long double __y);
  72. long double _FMAPI _fm_ldexpl (long double __x, int __exponent);
  73. long double _FMAPI _fm_log10l (long double __x);
  74. long double _FMAPI _fm_logl   (long double __x);
  75. long double _FMAPI _fm_sinhl  (long double __x);
  76. long double _FMAPI _fm_sinl   (long double __x);
  77. long double _FMAPI _fm_sqrtl  (long double __x);
  78. long double _FMAPI _fm_tanhl  (long double __x);
  79. long double _FMAPI _fm_tanl   (long double __x);
  80.  
  81. /* Additional fast functions, not directly supported in the regular RTL: */
  82.  
  83. /* double routines: */
  84. void _FMAPI _fm_sincos(double __a, double *__x, double *__y);
  85.  
  86. /* long double routines: */
  87. void _FMAPI _fm_sincosl(long double __a, long double *__x, long double *__y);
  88. long double _FMAPI              _fm_atanhl (long double __x);
  89. long double _FMAPI              _fm_acoshl (long double __x);
  90. long double _FMAPI              _fm_asinhl (long double __x);
  91.  
  92.  
  93. /* Special inline function that performs an intrinsic FWAIT instruction */
  94. __inline void _fm_fwait(void)
  95. {
  96.     __emit__(0x9B);  /* asm FWAIT */
  97. }
  98.  
  99. /* _fm_init can be called to mask all fpu exceptions prior to using the
  100.   FastMath routines.
  101. */
  102. unsigned int _FMAPI _fm_init(void);
  103.  
  104.  
  105. /* If you don't want the standard C function names re-mapped to the FastMath
  106.    versions, then define _FM_NO_REMAP.  The FastMath routines can still be
  107.    called with their _fm_xxx names.
  108. */
  109. #ifndef _FM_NO_REMAP
  110.  
  111. /* Undefine the standard functions names in preparation for re-mapping */
  112.  
  113. #undef acos
  114. #undef asin
  115. #undef atan
  116. #undef atan2
  117. #undef cos
  118. #undef cosh
  119. #undef exp
  120. #undef fabs
  121. #undef frexp
  122. #undef hypot
  123. #undef ldexp
  124. #undef log
  125. #undef log10
  126. #undef sin
  127. #undef sinh
  128. #undef sqrt
  129. #undef tan
  130. #undef tanh
  131. #undef sincos
  132.  
  133. #undef acosl
  134. #undef asinl
  135. #undef atan2l
  136. #undef atanl
  137. #undef coshl
  138. #undef cosl
  139. #undef expl
  140. #undef fabsl
  141. #undef frexpl
  142. #undef hypotl
  143. #undef ldexpl
  144. #undef log10l
  145. #undef logl
  146. #undef sinhl
  147. #undef sinl
  148. #undef sqrtl
  149. #undef tanhl
  150. #undef tanl
  151. #undef sincosl
  152.  
  153. #undef atanhl
  154. #undef acoshl
  155. #undef asinhl
  156.  
  157. /* now re-map the standard names to their FastMath equivalents */
  158.  
  159. #define acos      _fm_acos
  160. #define asin      _fm_asin
  161. #define atan      _fm_atan
  162. #define atan2     _fm_atan2
  163. #define cos       _fm_cos
  164. #define cosh      _fm_cosh
  165. #define exp       _fm_exp
  166. #define fabs      _fm_fabs
  167. #define frexp     _fm_frexp
  168. #define hypot     _fm_hypot
  169. #define ldexp     _fm_ldexp
  170. #define log       _fm_log
  171. #define log10     _fm_log10
  172. #define sin       _fm_sin
  173. #define sinh      _fm_sinh
  174. #define sqrt      _fm_sqrt
  175. #define tan       _fm_tan
  176. #define tanh      _fm_tanh
  177. #define sincos    _fm_sincos
  178.  
  179. #define acosl     _fm_acosl
  180. #define asinl     _fm_asinl
  181. #define atan2l    _fm_atan2l
  182. #define atanl     _fm_atanl
  183. #define coshl     _fm_coshl
  184. #define cosl      _fm_cosl
  185. #define expl      _fm_expl
  186. #define fabsl     _fm_fabsl
  187. #define frexpl    _fm_frexpl
  188. #define hypotl    _fm_hypotl
  189. #define ldexpl    _fm_ldexpl
  190. #define log10l    _fm_log10l
  191. #define logl      _fm_logl
  192. #define sinhl     _fm_sinhl
  193. #define sinl      _fm_sinl
  194. #define sqrtl     _fm_sqrtl
  195. #define tanhl     _fm_tanhl
  196. #define tanl      _fm_tanl
  197. #define sincosl   _fm_sincosl
  198.  
  199. #define atanhl    _fm_atanhl
  200. #define acoshl    _fm_acoshl
  201. #define asinhl    _fm_asinhl
  202.  
  203. #endif /* _FM_NO_REMAP */
  204.  
  205. #ifdef __cplusplus
  206. } // "C"
  207. #endif
  208.  
  209. #endif /* __FASTMATH_H */