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.

293 lines
7.1 KiB

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