Source code pulled from OpenBSD for OpenNTPD. The place to contribute to this code is via the OpenBSD CVS tree.
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.

278 lines
7.5 KiB

24 years ago
  1. /* $OpenBSD: math.h,v 1.4 2000/03/01 22:27:13 todd Exp $ */
  2. /*
  3. * ====================================================
  4. * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
  5. *
  6. * Developed at SunPro, a Sun Microsystems, Inc. business.
  7. * Permission to use, copy, modify, and distribute this
  8. * software is freely granted, provided that this notice
  9. * is preserved.
  10. * ====================================================
  11. */
  12. /*
  13. * from: @(#)fdlibm.h 5.1 93/09/24
  14. */
  15. #ifndef _MATH_H_
  16. #define _MATH_H_
  17. /*
  18. * ANSI/POSIX
  19. */
  20. extern char __infinity[];
  21. #define HUGE_VAL (*(double *) __infinity)
  22. /*
  23. * XOPEN/SVID
  24. */
  25. #if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
  26. #define M_E 2.7182818284590452354 /* e */
  27. #define M_LOG2E 1.4426950408889634074 /* log 2e */
  28. #define M_LOG10E 0.43429448190325182765 /* log 10e */
  29. #define M_LN2 0.69314718055994530942 /* log e2 */
  30. #define M_LN10 2.30258509299404568402 /* log e10 */
  31. #define M_PI 3.14159265358979323846 /* pi */
  32. #define M_PI_2 1.57079632679489661923 /* pi/2 */
  33. #define M_PI_4 0.78539816339744830962 /* pi/4 */
  34. #define M_1_PI 0.31830988618379067154 /* 1/pi */
  35. #define M_2_PI 0.63661977236758134308 /* 2/pi */
  36. #define M_2_SQRTPI 1.12837916709551257390 /* 2/sqrt(pi) */
  37. #define M_SQRT2 1.41421356237309504880 /* sqrt(2) */
  38. #define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */
  39. #define MAXFLOAT ((float)3.40282346638528860e+38)
  40. extern int signgam;
  41. #if !defined(_XOPEN_SOURCE)
  42. enum fdversion {fdlibm_ieee = -1, fdlibm_svid, fdlibm_xopen, fdlibm_posix};
  43. #define _LIB_VERSION_TYPE enum fdversion
  44. #define _LIB_VERSION _fdlib_version
  45. /* if global variable _LIB_VERSION is not desirable, one may
  46. * change the following to be a constant by:
  47. * #define _LIB_VERSION_TYPE const enum version
  48. * In that case, after one initializes the value _LIB_VERSION (see
  49. * s_lib_version.c) during compile time, it cannot be modified
  50. * in the middle of a program
  51. */
  52. extern _LIB_VERSION_TYPE _LIB_VERSION;
  53. #define _IEEE_ fdlibm_ieee
  54. #define _SVID_ fdlibm_svid
  55. #define _XOPEN_ fdlibm_xopen
  56. #define _POSIX_ fdlibm_posix
  57. #ifdef __LIBM_PRIVATE
  58. struct exception {
  59. int type;
  60. char *name;
  61. double arg1;
  62. double arg2;
  63. double retval;
  64. };
  65. #endif
  66. #define HUGE MAXFLOAT
  67. /*
  68. * set X_TLOSS = pi*2**52, which is possibly defined in <values.h>
  69. * (one may replace the following line by "#include <values.h>")
  70. */
  71. #define X_TLOSS 1.41484755040568800000e+16
  72. #define DOMAIN 1
  73. #define SING 2
  74. #define OVERFLOW 3
  75. #define UNDERFLOW 4
  76. #define TLOSS 5
  77. #define PLOSS 6
  78. #endif /* !_XOPEN_SOURCE */
  79. #endif /* !_ANSI_SOURCE && !_POSIX_SOURCE */
  80. #include <sys/cdefs.h>
  81. __BEGIN_DECLS
  82. /*
  83. * ANSI/POSIX
  84. */
  85. extern double acos __P((double));
  86. extern double asin __P((double));
  87. extern double atan __P((double));
  88. extern double atan2 __P((double, double));
  89. extern double cos __P((double));
  90. extern double sin __P((double));
  91. extern double tan __P((double));
  92. extern double cosh __P((double));
  93. extern double sinh __P((double));
  94. extern double tanh __P((double));
  95. extern double exp __P((double));
  96. extern double frexp __P((double, int *));
  97. extern double ldexp __P((double, int));
  98. extern double log __P((double));
  99. extern double log10 __P((double));
  100. extern double modf __P((double, double *));
  101. extern double pow __P((double, double));
  102. extern double sqrt __P((double));
  103. extern double ceil __P((double));
  104. extern double fabs __P((double));
  105. extern double floor __P((double));
  106. extern double fmod __P((double, double));
  107. #if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
  108. extern double erf __P((double));
  109. extern double erfc __P((double));
  110. extern double gamma __P((double));
  111. extern double hypot __P((double, double));
  112. extern int isinf __P((double));
  113. extern int isnan __P((double));
  114. extern int finite __P((double));
  115. extern double j0 __P((double));
  116. extern double j1 __P((double));
  117. extern double jn __P((int, double));
  118. extern double lgamma __P((double));
  119. extern double y0 __P((double));
  120. extern double y1 __P((double));
  121. extern double yn __P((int, double));
  122. #if !defined(_XOPEN_SOURCE)
  123. extern double acosh __P((double));
  124. extern double asinh __P((double));
  125. extern double atanh __P((double));
  126. extern double cbrt __P((double));
  127. extern double logb __P((double));
  128. extern double nextafter __P((double, double));
  129. extern double remainder __P((double, double));
  130. extern double scalb __P((double, double));
  131. #ifdef __LIBM_PRIVATE
  132. extern int matherr __P((struct exception *));
  133. #endif
  134. /*
  135. * IEEE Test Vector
  136. */
  137. extern double significand __P((double));
  138. /*
  139. * Functions callable from C, intended to support IEEE arithmetic.
  140. */
  141. extern double copysign __P((double, double));
  142. extern int ilogb __P((double));
  143. extern double rint __P((double));
  144. extern double scalbn __P((double, int));
  145. /*
  146. * BSD math library entry points
  147. */
  148. extern double cabs();
  149. extern double drem __P((double, double));
  150. extern double expm1 __P((double));
  151. extern double log1p __P((double));
  152. /*
  153. * Reentrant version of gamma & lgamma; passes signgam back by reference
  154. * as the second argument; user must allocate space for signgam.
  155. */
  156. #ifdef _REENTRANT
  157. extern double gamma_r __P((double, int *));
  158. extern double lgamma_r __P((double, int *));
  159. #endif /* _REENTRANT */
  160. /* float versions of ANSI/POSIX functions */
  161. extern float acosf __P((float));
  162. extern float asinf __P((float));
  163. extern float atanf __P((float));
  164. extern float atan2f __P((float, float));
  165. extern float cosf __P((float));
  166. extern float sinf __P((float));
  167. extern float tanf __P((float));
  168. extern float coshf __P((float));
  169. extern float sinhf __P((float));
  170. extern float tanhf __P((float));
  171. extern float expf __P((float));
  172. extern float frexpf __P((float, int *));
  173. extern float ldexpf __P((float, int));
  174. extern float logf __P((float));
  175. extern float log10f __P((float));
  176. extern float modff __P((float, float *));
  177. extern float powf __P((float, float));
  178. extern float sqrtf __P((float));
  179. extern float ceilf __P((float));
  180. extern float fabsf __P((float));
  181. extern float floorf __P((float));
  182. extern float fmodf __P((float, float));
  183. extern float erff __P((float));
  184. extern float erfcf __P((float));
  185. extern float gammaf __P((float));
  186. extern float hypotf __P((float, float));
  187. extern int isinff __P((float));
  188. extern int isnanf __P((float));
  189. extern int finitef __P((float));
  190. extern float j0f __P((float));
  191. extern float j1f __P((float));
  192. extern float jnf __P((int, float));
  193. extern float lgammaf __P((float));
  194. extern float y0f __P((float));
  195. extern float y1f __P((float));
  196. extern float ynf __P((int, float));
  197. extern float acoshf __P((float));
  198. extern float asinhf __P((float));
  199. extern float atanhf __P((float));
  200. extern float cbrtf __P((float));
  201. extern float logbf __P((float));
  202. extern float nextafterf __P((float, float));
  203. extern float remainderf __P((float, float));
  204. extern float scalbf __P((float, float));
  205. /*
  206. * float version of IEEE Test Vector
  207. */
  208. extern float significandf __P((float));
  209. /*
  210. * Float versions of functions callable from C, intended to support
  211. * IEEE arithmetic.
  212. */
  213. extern float copysignf __P((float, float));
  214. extern int ilogbf __P((float));
  215. extern float rintf __P((float));
  216. extern float scalbnf __P((float, int));
  217. /*
  218. * float versions of BSD math library entry points
  219. */
  220. extern float cabsf ();
  221. extern float dremf __P((float, float));
  222. extern float expm1f __P((float));
  223. extern float log1pf __P((float));
  224. /*
  225. * Float versions of reentrant version of gamma & lgamma; passes
  226. * signgam back by reference as the second argument; user must
  227. * allocate space for signgam.
  228. */
  229. #ifdef _REENTRANT
  230. extern float gammaf_r __P((float, int *));
  231. extern float lgammaf_r __P((float, int *));
  232. #endif /* _REENTRANT */
  233. #endif /* !_XOPEN_SOURCE */
  234. #endif /* !_ANSI_SOURCE && !_POSIX_SOURCE */
  235. __END_DECLS
  236. #endif /* _MATH_H_ */