2007-02-23 01:08:17 +03:00
|
|
|
/* $NetBSD: math.h,v 1.46 2007/02/22 22:08:19 drochner Exp $ */
|
1994-10-26 03:55:40 +03:00
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
/*
|
1994-02-11 21:36:42 +03:00
|
|
|
* ====================================================
|
|
|
|
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
|
1993-03-21 12:45:37 +03:00
|
|
|
*
|
1994-02-11 21:36:42 +03:00
|
|
|
* Developed at SunPro, a Sun Microsystems, Inc. business.
|
|
|
|
* Permission to use, copy, modify, and distribute this
|
2004-07-10 17:49:09 +04:00
|
|
|
* software is freely granted, provided that this notice
|
1994-02-11 21:36:42 +03:00
|
|
|
* is preserved.
|
|
|
|
* ====================================================
|
1993-03-21 12:45:37 +03:00
|
|
|
*/
|
|
|
|
|
1994-02-11 21:36:42 +03:00
|
|
|
/*
|
1994-10-26 03:55:40 +03:00
|
|
|
* @(#)fdlibm.h 5.1 93/09/24
|
1994-02-11 21:36:42 +03:00
|
|
|
*/
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1994-02-11 21:36:42 +03:00
|
|
|
#ifndef _MATH_H_
|
1994-02-14 05:11:39 +03:00
|
|
|
#define _MATH_H_
|
1993-03-21 12:45:37 +03:00
|
|
|
|
2000-01-04 17:20:05 +03:00
|
|
|
#include <sys/cdefs.h>
|
1998-05-07 22:50:08 +04:00
|
|
|
#include <sys/featuretest.h>
|
2002-02-19 16:08:12 +03:00
|
|
|
|
|
|
|
union __float_u {
|
|
|
|
unsigned char __dummy[sizeof(float)];
|
|
|
|
float __val;
|
|
|
|
};
|
|
|
|
|
|
|
|
union __double_u {
|
|
|
|
unsigned char __dummy[sizeof(double)];
|
|
|
|
double __val;
|
|
|
|
};
|
|
|
|
|
2003-05-18 00:42:28 +04:00
|
|
|
union __long_double_u {
|
|
|
|
unsigned char __dummy[sizeof(long double)];
|
|
|
|
long double __val;
|
|
|
|
};
|
|
|
|
|
|
|
|
#include <machine/math.h> /* may use __float_u, __double_u,
|
|
|
|
or __long_double_u */
|
1998-05-07 22:50:08 +04:00
|
|
|
|
2004-01-15 22:43:44 +03:00
|
|
|
#ifdef __HAVE_LONG_DOUBLE
|
|
|
|
#define __fpmacro_unary_floating(__name, __arg0) \
|
2004-03-04 03:17:44 +03:00
|
|
|
/* LINTED */ \
|
2004-01-15 22:43:44 +03:00
|
|
|
((sizeof (__arg0) == sizeof (float)) \
|
|
|
|
? __ ## __name ## f (__arg0) \
|
|
|
|
: (sizeof (__arg0) == sizeof (double)) \
|
|
|
|
? __ ## __name ## d (__arg0) \
|
|
|
|
: __ ## __name ## l (__arg0))
|
|
|
|
#else
|
|
|
|
#define __fpmacro_unary_floating(__name, __arg0) \
|
2004-03-04 03:17:44 +03:00
|
|
|
/* LINTED */ \
|
2004-01-15 22:43:44 +03:00
|
|
|
((sizeof (__arg0) == sizeof (float)) \
|
|
|
|
? __ ## __name ## f (__arg0) \
|
|
|
|
: __ ## __name ## d (__arg0))
|
2004-01-17 04:04:46 +03:00
|
|
|
#endif /* __HAVE_LONG_DOUBLE */
|
2004-01-15 22:43:44 +03:00
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
/*
|
1994-02-11 21:36:42 +03:00
|
|
|
* ANSI/POSIX
|
1993-03-21 12:45:37 +03:00
|
|
|
*/
|
2003-10-26 03:02:02 +03:00
|
|
|
/* 7.12#3 HUGE_VAL, HUGELF, HUGE_VALL */
|
2005-12-24 22:12:23 +03:00
|
|
|
extern const union __double_u __infinity;
|
2002-02-19 16:08:12 +03:00
|
|
|
#define HUGE_VAL __infinity.__val
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ISO C99
|
|
|
|
*/
|
2003-10-26 02:35:46 +04:00
|
|
|
#if !defined(_ANSI_SOURCE) && !defined(_POSIX_C_SOURCE) && \
|
|
|
|
!defined(_XOPEN_SOURCE) || \
|
|
|
|
((__STDC_VERSION__ - 0) >= 199901L) || \
|
|
|
|
((_POSIX_C_SOURCE - 0) >= 200112L) || \
|
|
|
|
((_XOPEN_SOURCE - 0) >= 600) || \
|
|
|
|
defined(_ISOC99_SOURCE) || defined(_NETBSD_SOURCE)
|
2003-10-26 03:02:02 +03:00
|
|
|
/* 7.12#3 HUGE_VAL, HUGELF, HUGE_VALL */
|
2005-12-24 22:12:23 +03:00
|
|
|
extern const union __float_u __infinityf;
|
2003-10-26 02:35:46 +04:00
|
|
|
#define HUGE_VALF __infinityf.__val
|
|
|
|
|
2005-12-24 22:12:23 +03:00
|
|
|
extern const union __long_double_u __infinityl;
|
2003-10-26 02:35:46 +04:00
|
|
|
#define HUGE_VALL __infinityl.__val
|
|
|
|
|
2003-10-26 03:02:02 +03:00
|
|
|
/* 7.12#4 INFINITY */
|
|
|
|
#ifdef __INFINITY
|
|
|
|
#define INFINITY __INFINITY /* float constant which overflows */
|
|
|
|
#else
|
|
|
|
#define INFINITY HUGE_VALF /* positive infinity */
|
|
|
|
#endif /* __INFINITY */
|
|
|
|
|
|
|
|
/* 7.12#5 NAN: a quiet NaN, if supported */
|
2003-10-26 02:35:46 +04:00
|
|
|
#ifdef __HAVE_NANF
|
2005-12-24 22:12:23 +03:00
|
|
|
extern const union __float_u __nanf;
|
2002-02-19 16:08:12 +03:00
|
|
|
#define NAN __nanf.__val
|
2003-10-26 02:35:46 +04:00
|
|
|
#endif /* __HAVE_NANF */
|
2004-01-15 22:43:44 +03:00
|
|
|
|
|
|
|
/* 7.12#6 number classification macros */
|
|
|
|
#define FP_INFINITE 0x00
|
|
|
|
#define FP_NAN 0x01
|
|
|
|
#define FP_NORMAL 0x02
|
|
|
|
#define FP_SUBNORMAL 0x03
|
|
|
|
#define FP_ZERO 0x04
|
|
|
|
/* NetBSD extensions */
|
|
|
|
#define _FP_LOMD 0x80 /* range for machine-specific classes */
|
|
|
|
#define _FP_HIMD 0xff
|
|
|
|
|
2003-10-26 02:35:46 +04:00
|
|
|
#endif /* !_ANSI_SOURCE && ... */
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1994-02-11 21:36:42 +03:00
|
|
|
/*
|
|
|
|
* XOPEN/SVID
|
|
|
|
*/
|
Add a new feature-test macro, _NETBSD_SOURCE. If this is defined
by the application, all NetBSD interfaces are made visible, even
if some other feature-test macro (like _POSIX_C_SOURCE) is defined.
<sys/featuretest.h> defined _NETBSD_SOURCE if none of _ANSI_SOURCE,
_POSIX_C_SOURCE and _XOPEN_SOURCE is defined, so as to preserve
existing behaviour.
This has two major advantages:
+ Programs that require non-POSIX facilities but define _POSIX_C_SOURCE
can trivially be overruled by putting -D_NETBSD_SOURCE in their CFLAGS.
+ It makes most of the #ifs simpler, in that they're all now ORs of the
various macros, rather than having checks for (!defined(_ANSI_SOURCE) ||
!defined(_POSIX_C_SOURCE) || !defined(_XOPEN_SOURCE)) all over the place.
I've tried not to change the semantics of the headers in any case where
_NETBSD_SOURCE wasn't defined, but there were some places where the
current semantics were clearly mad, and retaining them was harder than
correcting them. In particular, I've mostly normalised things so that
_ANSI_SOURCE gets you the smallest set of stuff, then _POSIX_C_SOURCE,
_XOPEN_SOURCE and _NETBSD_SOURCE in that order.
Tested by building for vax, encouraged by thorpej, and uncontested in
tech-userlevel for a week.
2003-04-29 03:16:11 +04:00
|
|
|
#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)
|
1993-03-21 12:45:37 +03:00
|
|
|
#define M_E 2.7182818284590452354 /* e */
|
|
|
|
#define M_LOG2E 1.4426950408889634074 /* log 2e */
|
|
|
|
#define M_LOG10E 0.43429448190325182765 /* log 10e */
|
|
|
|
#define M_LN2 0.69314718055994530942 /* log e2 */
|
|
|
|
#define M_LN10 2.30258509299404568402 /* log e10 */
|
|
|
|
#define M_PI 3.14159265358979323846 /* pi */
|
|
|
|
#define M_PI_2 1.57079632679489661923 /* pi/2 */
|
|
|
|
#define M_PI_4 0.78539816339744830962 /* pi/4 */
|
|
|
|
#define M_1_PI 0.31830988618379067154 /* 1/pi */
|
|
|
|
#define M_2_PI 0.63661977236758134308 /* 2/pi */
|
|
|
|
#define M_2_SQRTPI 1.12837916709551257390 /* 2/sqrt(pi) */
|
|
|
|
#define M_SQRT2 1.41421356237309504880 /* sqrt(2) */
|
|
|
|
#define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */
|
|
|
|
|
1994-02-11 21:36:42 +03:00
|
|
|
#define MAXFLOAT ((float)3.40282346638528860e+38)
|
|
|
|
extern int signgam;
|
Add a new feature-test macro, _NETBSD_SOURCE. If this is defined
by the application, all NetBSD interfaces are made visible, even
if some other feature-test macro (like _POSIX_C_SOURCE) is defined.
<sys/featuretest.h> defined _NETBSD_SOURCE if none of _ANSI_SOURCE,
_POSIX_C_SOURCE and _XOPEN_SOURCE is defined, so as to preserve
existing behaviour.
This has two major advantages:
+ Programs that require non-POSIX facilities but define _POSIX_C_SOURCE
can trivially be overruled by putting -D_NETBSD_SOURCE in their CFLAGS.
+ It makes most of the #ifs simpler, in that they're all now ORs of the
various macros, rather than having checks for (!defined(_ANSI_SOURCE) ||
!defined(_POSIX_C_SOURCE) || !defined(_XOPEN_SOURCE)) all over the place.
I've tried not to change the semantics of the headers in any case where
_NETBSD_SOURCE wasn't defined, but there were some places where the
current semantics were clearly mad, and retaining them was harder than
correcting them. In particular, I've mostly normalised things so that
_ANSI_SOURCE gets you the smallest set of stuff, then _POSIX_C_SOURCE,
_XOPEN_SOURCE and _NETBSD_SOURCE in that order.
Tested by building for vax, encouraged by thorpej, and uncontested in
tech-userlevel for a week.
2003-04-29 03:16:11 +04:00
|
|
|
#endif /* _XOPEN_SOURCE || _NETBSD_SOURCE */
|
1994-02-11 21:36:42 +03:00
|
|
|
|
Add a new feature-test macro, _NETBSD_SOURCE. If this is defined
by the application, all NetBSD interfaces are made visible, even
if some other feature-test macro (like _POSIX_C_SOURCE) is defined.
<sys/featuretest.h> defined _NETBSD_SOURCE if none of _ANSI_SOURCE,
_POSIX_C_SOURCE and _XOPEN_SOURCE is defined, so as to preserve
existing behaviour.
This has two major advantages:
+ Programs that require non-POSIX facilities but define _POSIX_C_SOURCE
can trivially be overruled by putting -D_NETBSD_SOURCE in their CFLAGS.
+ It makes most of the #ifs simpler, in that they're all now ORs of the
various macros, rather than having checks for (!defined(_ANSI_SOURCE) ||
!defined(_POSIX_C_SOURCE) || !defined(_XOPEN_SOURCE)) all over the place.
I've tried not to change the semantics of the headers in any case where
_NETBSD_SOURCE wasn't defined, but there were some places where the
current semantics were clearly mad, and retaining them was harder than
correcting them. In particular, I've mostly normalised things so that
_ANSI_SOURCE gets you the smallest set of stuff, then _POSIX_C_SOURCE,
_XOPEN_SOURCE and _NETBSD_SOURCE in that order.
Tested by building for vax, encouraged by thorpej, and uncontested in
tech-userlevel for a week.
2003-04-29 03:16:11 +04:00
|
|
|
#if defined(_NETBSD_SOURCE)
|
1994-02-11 21:36:42 +03:00
|
|
|
enum fdversion {fdlibm_ieee = -1, fdlibm_svid, fdlibm_xopen, fdlibm_posix};
|
|
|
|
|
|
|
|
#define _LIB_VERSION_TYPE enum fdversion
|
2004-07-10 17:49:09 +04:00
|
|
|
#define _LIB_VERSION _fdlib_version
|
1993-03-21 12:45:37 +03:00
|
|
|
|
2004-07-10 17:49:09 +04:00
|
|
|
/* if global variable _LIB_VERSION is not desirable, one may
|
|
|
|
* change the following to be a constant by:
|
1994-02-11 21:36:42 +03:00
|
|
|
* #define _LIB_VERSION_TYPE const enum version
|
|
|
|
* In that case, after one initializes the value _LIB_VERSION (see
|
|
|
|
* s_lib_version.c) during compile time, it cannot be modified
|
|
|
|
* in the middle of a program
|
2004-07-10 17:49:09 +04:00
|
|
|
*/
|
1994-02-11 21:36:42 +03:00
|
|
|
extern _LIB_VERSION_TYPE _LIB_VERSION;
|
|
|
|
|
|
|
|
#define _IEEE_ fdlibm_ieee
|
|
|
|
#define _SVID_ fdlibm_svid
|
|
|
|
#define _XOPEN_ fdlibm_xopen
|
|
|
|
#define _POSIX_ fdlibm_posix
|
|
|
|
|
1998-04-09 03:42:59 +04:00
|
|
|
#ifndef __cplusplus
|
1994-02-11 21:36:42 +03:00
|
|
|
struct exception {
|
|
|
|
int type;
|
|
|
|
char *name;
|
|
|
|
double arg1;
|
|
|
|
double arg2;
|
|
|
|
double retval;
|
|
|
|
};
|
1998-04-09 03:42:59 +04:00
|
|
|
#endif
|
1994-02-11 21:36:42 +03:00
|
|
|
|
|
|
|
#define HUGE MAXFLOAT
|
|
|
|
|
2004-07-10 17:49:09 +04:00
|
|
|
/*
|
1994-02-11 21:36:42 +03:00
|
|
|
* set X_TLOSS = pi*2**52, which is possibly defined in <values.h>
|
|
|
|
* (one may replace the following line by "#include <values.h>")
|
|
|
|
*/
|
|
|
|
|
2004-07-10 17:49:09 +04:00
|
|
|
#define X_TLOSS 1.41484755040568800000e+16
|
1994-02-11 21:36:42 +03:00
|
|
|
|
|
|
|
#define DOMAIN 1
|
|
|
|
#define SING 2
|
|
|
|
#define OVERFLOW 3
|
|
|
|
#define UNDERFLOW 4
|
|
|
|
#define TLOSS 5
|
|
|
|
#define PLOSS 6
|
|
|
|
|
Add a new feature-test macro, _NETBSD_SOURCE. If this is defined
by the application, all NetBSD interfaces are made visible, even
if some other feature-test macro (like _POSIX_C_SOURCE) is defined.
<sys/featuretest.h> defined _NETBSD_SOURCE if none of _ANSI_SOURCE,
_POSIX_C_SOURCE and _XOPEN_SOURCE is defined, so as to preserve
existing behaviour.
This has two major advantages:
+ Programs that require non-POSIX facilities but define _POSIX_C_SOURCE
can trivially be overruled by putting -D_NETBSD_SOURCE in their CFLAGS.
+ It makes most of the #ifs simpler, in that they're all now ORs of the
various macros, rather than having checks for (!defined(_ANSI_SOURCE) ||
!defined(_POSIX_C_SOURCE) || !defined(_XOPEN_SOURCE)) all over the place.
I've tried not to change the semantics of the headers in any case where
_NETBSD_SOURCE wasn't defined, but there were some places where the
current semantics were clearly mad, and retaining them was harder than
correcting them. In particular, I've mostly normalised things so that
_ANSI_SOURCE gets you the smallest set of stuff, then _POSIX_C_SOURCE,
_XOPEN_SOURCE and _NETBSD_SOURCE in that order.
Tested by building for vax, encouraged by thorpej, and uncontested in
tech-userlevel for a week.
2003-04-29 03:16:11 +04:00
|
|
|
#endif /* _NETBSD_SOURCE */
|
1994-02-11 21:36:42 +03:00
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
__BEGIN_DECLS
|
1994-02-11 21:36:42 +03:00
|
|
|
/*
|
|
|
|
* ANSI/POSIX
|
|
|
|
*/
|
2005-02-03 07:39:32 +03:00
|
|
|
double acos(double);
|
|
|
|
double asin(double);
|
|
|
|
double atan(double);
|
|
|
|
double atan2(double, double);
|
|
|
|
double cos(double);
|
|
|
|
double sin(double);
|
|
|
|
double tan(double);
|
|
|
|
|
|
|
|
double cosh(double);
|
|
|
|
double sinh(double);
|
|
|
|
double tanh(double);
|
|
|
|
|
|
|
|
double exp(double);
|
|
|
|
double frexp(double, int *);
|
|
|
|
double ldexp(double, int);
|
|
|
|
double log(double);
|
2005-07-21 16:56:29 +04:00
|
|
|
double log2(double);
|
2005-02-03 07:39:32 +03:00
|
|
|
double log10(double);
|
|
|
|
double modf(double, double *);
|
|
|
|
|
|
|
|
double pow(double, double);
|
|
|
|
double sqrt(double);
|
|
|
|
|
|
|
|
double ceil(double);
|
|
|
|
double fabs(double);
|
|
|
|
double floor(double);
|
|
|
|
double fmod(double, double);
|
1993-03-21 12:45:37 +03:00
|
|
|
|
Add a new feature-test macro, _NETBSD_SOURCE. If this is defined
by the application, all NetBSD interfaces are made visible, even
if some other feature-test macro (like _POSIX_C_SOURCE) is defined.
<sys/featuretest.h> defined _NETBSD_SOURCE if none of _ANSI_SOURCE,
_POSIX_C_SOURCE and _XOPEN_SOURCE is defined, so as to preserve
existing behaviour.
This has two major advantages:
+ Programs that require non-POSIX facilities but define _POSIX_C_SOURCE
can trivially be overruled by putting -D_NETBSD_SOURCE in their CFLAGS.
+ It makes most of the #ifs simpler, in that they're all now ORs of the
various macros, rather than having checks for (!defined(_ANSI_SOURCE) ||
!defined(_POSIX_C_SOURCE) || !defined(_XOPEN_SOURCE)) all over the place.
I've tried not to change the semantics of the headers in any case where
_NETBSD_SOURCE wasn't defined, but there were some places where the
current semantics were clearly mad, and retaining them was harder than
correcting them. In particular, I've mostly normalised things so that
_ANSI_SOURCE gets you the smallest set of stuff, then _POSIX_C_SOURCE,
_XOPEN_SOURCE and _NETBSD_SOURCE in that order.
Tested by building for vax, encouraged by thorpej, and uncontested in
tech-userlevel for a week.
2003-04-29 03:16:11 +04:00
|
|
|
#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)
|
2005-02-03 07:39:32 +03:00
|
|
|
double erf(double);
|
|
|
|
double erfc(double);
|
|
|
|
double gamma(double);
|
|
|
|
double hypot(double, double);
|
|
|
|
int finite(double);
|
|
|
|
double j0(double);
|
|
|
|
double j1(double);
|
|
|
|
double jn(int, double);
|
|
|
|
double lgamma(double);
|
|
|
|
double y0(double);
|
|
|
|
double y1(double);
|
|
|
|
double yn(int, double);
|
1994-02-11 21:36:42 +03:00
|
|
|
|
Add a new feature-test macro, _NETBSD_SOURCE. If this is defined
by the application, all NetBSD interfaces are made visible, even
if some other feature-test macro (like _POSIX_C_SOURCE) is defined.
<sys/featuretest.h> defined _NETBSD_SOURCE if none of _ANSI_SOURCE,
_POSIX_C_SOURCE and _XOPEN_SOURCE is defined, so as to preserve
existing behaviour.
This has two major advantages:
+ Programs that require non-POSIX facilities but define _POSIX_C_SOURCE
can trivially be overruled by putting -D_NETBSD_SOURCE in their CFLAGS.
+ It makes most of the #ifs simpler, in that they're all now ORs of the
various macros, rather than having checks for (!defined(_ANSI_SOURCE) ||
!defined(_POSIX_C_SOURCE) || !defined(_XOPEN_SOURCE)) all over the place.
I've tried not to change the semantics of the headers in any case where
_NETBSD_SOURCE wasn't defined, but there were some places where the
current semantics were clearly mad, and retaining them was harder than
correcting them. In particular, I've mostly normalised things so that
_ANSI_SOURCE gets you the smallest set of stuff, then _POSIX_C_SOURCE,
_XOPEN_SOURCE and _NETBSD_SOURCE in that order.
Tested by building for vax, encouraged by thorpej, and uncontested in
tech-userlevel for a week.
2003-04-29 03:16:11 +04:00
|
|
|
#if (_XOPEN_SOURCE - 0) >= 500 || defined(_NETBSD_SOURCE)
|
2005-02-03 07:39:32 +03:00
|
|
|
double acosh(double);
|
|
|
|
double asinh(double);
|
|
|
|
double atanh(double);
|
|
|
|
double cbrt(double);
|
|
|
|
double expm1(double);
|
|
|
|
int ilogb(double);
|
|
|
|
double log1p(double);
|
|
|
|
double logb(double);
|
|
|
|
double nextafter(double, double);
|
|
|
|
double remainder(double, double);
|
|
|
|
double rint(double);
|
|
|
|
double scalb(double, double);
|
Add a new feature-test macro, _NETBSD_SOURCE. If this is defined
by the application, all NetBSD interfaces are made visible, even
if some other feature-test macro (like _POSIX_C_SOURCE) is defined.
<sys/featuretest.h> defined _NETBSD_SOURCE if none of _ANSI_SOURCE,
_POSIX_C_SOURCE and _XOPEN_SOURCE is defined, so as to preserve
existing behaviour.
This has two major advantages:
+ Programs that require non-POSIX facilities but define _POSIX_C_SOURCE
can trivially be overruled by putting -D_NETBSD_SOURCE in their CFLAGS.
+ It makes most of the #ifs simpler, in that they're all now ORs of the
various macros, rather than having checks for (!defined(_ANSI_SOURCE) ||
!defined(_POSIX_C_SOURCE) || !defined(_XOPEN_SOURCE)) all over the place.
I've tried not to change the semantics of the headers in any case where
_NETBSD_SOURCE wasn't defined, but there were some places where the
current semantics were clearly mad, and retaining them was harder than
correcting them. In particular, I've mostly normalised things so that
_ANSI_SOURCE gets you the smallest set of stuff, then _POSIX_C_SOURCE,
_XOPEN_SOURCE and _NETBSD_SOURCE in that order.
Tested by building for vax, encouraged by thorpej, and uncontested in
tech-userlevel for a week.
2003-04-29 03:16:11 +04:00
|
|
|
#endif /* (_XOPEN_SOURCE - 0) >= 500 || defined(_NETBSD_SOURCE)*/
|
|
|
|
#endif /* _XOPEN_SOURCE || _NETBSD_SOURCE */
|
1994-02-11 21:36:42 +03:00
|
|
|
|
2004-01-15 22:43:44 +03:00
|
|
|
/*
|
|
|
|
* ISO C99
|
|
|
|
*/
|
|
|
|
#if !defined(_ANSI_SOURCE) && !defined(_POSIX_C_SOURCE) && \
|
|
|
|
!defined(_XOPEN_SOURCE) || \
|
|
|
|
((__STDC_VERSION__ - 0) >= 199901L) || \
|
|
|
|
((_POSIX_C_SOURCE - 0) >= 200112L) || \
|
|
|
|
((_XOPEN_SOURCE - 0) >= 600) || \
|
|
|
|
defined(_ISOC99_SOURCE) || defined(_NETBSD_SOURCE)
|
|
|
|
/* 7.12.3.1 int fpclassify(real-floating x) */
|
|
|
|
#define fpclassify(__x) __fpmacro_unary_floating(fpclassify, __x)
|
|
|
|
|
|
|
|
/* 7.12.3.2 int isfinite(real-floating x) */
|
|
|
|
#define isfinite(__x) __fpmacro_unary_floating(isfinite, __x)
|
|
|
|
|
|
|
|
/* 7.12.3.5 int isnormal(real-floating x) */
|
|
|
|
#define isnormal(__x) (fpclassify(__x) == FP_NORMAL)
|
|
|
|
|
|
|
|
/* 7.12.3.6 int signbit(real-floating x) */
|
|
|
|
#define signbit(__x) __fpmacro_unary_floating(signbit, __x)
|
|
|
|
|
2004-06-30 19:11:05 +04:00
|
|
|
/* 7.12.4 trigonometric */
|
|
|
|
|
2005-02-03 07:39:32 +03:00
|
|
|
float acosf(float);
|
|
|
|
float asinf(float);
|
|
|
|
float atanf(float);
|
|
|
|
float atan2f(float, float);
|
|
|
|
float cosf(float);
|
|
|
|
float sinf(float);
|
|
|
|
float tanf(float);
|
2004-06-30 19:11:05 +04:00
|
|
|
|
|
|
|
/* 7.12.5 hyperbolic */
|
|
|
|
|
2005-02-03 07:39:32 +03:00
|
|
|
float acoshf(float);
|
|
|
|
float asinhf(float);
|
|
|
|
float atanhf(float);
|
|
|
|
float coshf(float);
|
|
|
|
float sinhf(float);
|
|
|
|
float tanhf(float);
|
2004-06-30 19:11:05 +04:00
|
|
|
|
|
|
|
/* 7.12.6 exp / log */
|
|
|
|
|
2005-02-03 07:39:32 +03:00
|
|
|
float expf(float);
|
|
|
|
float expm1f(float);
|
|
|
|
float frexpf(float, int *);
|
|
|
|
int ilogbf(float);
|
|
|
|
float ldexpf(float, int);
|
|
|
|
float logf(float);
|
2005-07-21 16:56:29 +04:00
|
|
|
float log2f(float);
|
2005-02-03 07:39:32 +03:00
|
|
|
float log10f(float);
|
|
|
|
float log1pf(float);
|
|
|
|
float logbf(float);
|
|
|
|
float modff(float, float *);
|
|
|
|
float scalbnf(float, int);
|
2004-06-30 19:11:05 +04:00
|
|
|
|
|
|
|
/* 7.12.7 power / absolute */
|
|
|
|
|
2005-02-03 07:39:32 +03:00
|
|
|
float cbrtf(float);
|
|
|
|
float fabsf(float);
|
|
|
|
float hypotf(float, float);
|
|
|
|
float powf(float, float);
|
|
|
|
float sqrtf(float);
|
2004-06-30 19:11:05 +04:00
|
|
|
|
|
|
|
/* 7.12.8 error / gamma */
|
|
|
|
|
2005-02-03 07:39:32 +03:00
|
|
|
float erff(float);
|
|
|
|
float erfcf(float);
|
|
|
|
float lgammaf(float);
|
2004-06-30 19:11:05 +04:00
|
|
|
|
|
|
|
/* 7.12.9 nearest integer */
|
|
|
|
|
2005-02-03 07:39:32 +03:00
|
|
|
float ceilf(float);
|
|
|
|
float floorf(float);
|
|
|
|
float rintf(float);
|
|
|
|
double round(double);
|
|
|
|
float roundf(float);
|
2006-03-25 19:41:11 +03:00
|
|
|
double trunc(double);
|
|
|
|
float truncf(float);
|
2005-02-03 07:39:32 +03:00
|
|
|
long int lrint(double);
|
|
|
|
long int lrintf(float);
|
2004-06-30 21:51:09 +04:00
|
|
|
/* LONGLONG */
|
2005-02-03 07:39:32 +03:00
|
|
|
long long int llrint(double);
|
2004-06-30 21:51:09 +04:00
|
|
|
/* LONGLONG */
|
2005-02-03 07:39:32 +03:00
|
|
|
long long int llrintf(float);
|
|
|
|
long int lround(double);
|
|
|
|
long int lroundf(float);
|
2004-07-01 20:09:21 +04:00
|
|
|
/* LONGLONG */
|
2005-02-03 07:39:32 +03:00
|
|
|
long long int llround(double);
|
2004-07-01 20:09:21 +04:00
|
|
|
/* LONGLONG */
|
2005-02-03 07:39:32 +03:00
|
|
|
long long int llroundf(float);
|
2004-06-30 19:11:05 +04:00
|
|
|
|
|
|
|
/* 7.12.10 remainder */
|
|
|
|
|
2005-02-03 07:39:32 +03:00
|
|
|
float fmodf(float, float);
|
|
|
|
float remainderf(float, float);
|
2004-06-30 19:11:05 +04:00
|
|
|
|
2007-02-06 20:29:37 +03:00
|
|
|
/* 7.12.11 manipulation */
|
2004-06-30 19:11:05 +04:00
|
|
|
|
2005-02-03 07:39:32 +03:00
|
|
|
float copysignf(float, float);
|
2006-03-23 19:55:42 +03:00
|
|
|
double nan(const char *);
|
|
|
|
float nanf(const char *);
|
|
|
|
long double nanl(const char *);
|
2005-02-03 07:39:32 +03:00
|
|
|
float nextafterf(float, float);
|
2004-06-30 19:11:05 +04:00
|
|
|
|
2007-02-06 20:29:37 +03:00
|
|
|
/* 7.12.14 comparision */
|
|
|
|
|
|
|
|
#define isunordered(x, y) (isnan(x) || isnan(y))
|
|
|
|
#define isgreater(x, y) (!isunordered((x), (y)) && (x) > (y))
|
|
|
|
#define isgreaterequal(x, y) (!isunordered((x), (y)) && (x) >= (y))
|
|
|
|
#define isless(x, y) (!isunordered((x), (y)) && (x) < (y))
|
|
|
|
#define islessequal(x, y) (!isunordered((x), (y)) && (x) <= (y))
|
|
|
|
#define islessgreater(x, y) (!isunordered((x), (y)) && \
|
|
|
|
((x) > (y) || (y) > (x)))
|
2004-06-30 19:11:05 +04:00
|
|
|
|
2004-01-15 22:43:44 +03:00
|
|
|
#endif /* !_ANSI_SOURCE && ... */
|
|
|
|
|
2004-03-05 02:42:38 +03:00
|
|
|
#if !defined(_ANSI_SOURCE) && !defined(_POSIX_C_SOURCE) || \
|
|
|
|
!defined(_XOPEN_SOURCE) || \
|
|
|
|
((__STDC_VERSION__ - 0) >= 199901L) || \
|
|
|
|
((_POSIX_C_SOURCE - 0) >= 200112L) || \
|
|
|
|
defined(_ISOC99_SOURCE) || defined(_NETBSD_SOURCE)
|
|
|
|
/* 7.12.3.3 int isinf(real-floating x) */
|
|
|
|
#ifdef __isinf
|
|
|
|
#define isinf(__x) __isinf(__x)
|
|
|
|
#else
|
|
|
|
#define isinf(__x) __fpmacro_unary_floating(isinf, __x)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* 7.12.3.4 int isnan(real-floating x) */
|
|
|
|
#ifdef __isnan
|
|
|
|
#define isnan(__x) __isnan(__x)
|
|
|
|
#else
|
|
|
|
#define isnan(__x) __fpmacro_unary_floating(isnan, __x)
|
|
|
|
#endif
|
|
|
|
#endif /* !_ANSI_SOURCE && ... */
|
|
|
|
|
Add a new feature-test macro, _NETBSD_SOURCE. If this is defined
by the application, all NetBSD interfaces are made visible, even
if some other feature-test macro (like _POSIX_C_SOURCE) is defined.
<sys/featuretest.h> defined _NETBSD_SOURCE if none of _ANSI_SOURCE,
_POSIX_C_SOURCE and _XOPEN_SOURCE is defined, so as to preserve
existing behaviour.
This has two major advantages:
+ Programs that require non-POSIX facilities but define _POSIX_C_SOURCE
can trivially be overruled by putting -D_NETBSD_SOURCE in their CFLAGS.
+ It makes most of the #ifs simpler, in that they're all now ORs of the
various macros, rather than having checks for (!defined(_ANSI_SOURCE) ||
!defined(_POSIX_C_SOURCE) || !defined(_XOPEN_SOURCE)) all over the place.
I've tried not to change the semantics of the headers in any case where
_NETBSD_SOURCE wasn't defined, but there were some places where the
current semantics were clearly mad, and retaining them was harder than
correcting them. In particular, I've mostly normalised things so that
_ANSI_SOURCE gets you the smallest set of stuff, then _POSIX_C_SOURCE,
_XOPEN_SOURCE and _NETBSD_SOURCE in that order.
Tested by building for vax, encouraged by thorpej, and uncontested in
tech-userlevel for a week.
2003-04-29 03:16:11 +04:00
|
|
|
#if defined(_NETBSD_SOURCE)
|
1998-04-09 03:42:59 +04:00
|
|
|
#ifndef __cplusplus
|
2005-02-03 07:39:32 +03:00
|
|
|
int matherr(struct exception *);
|
1998-04-09 03:42:59 +04:00
|
|
|
#endif
|
1994-02-11 21:36:42 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* IEEE Test Vector
|
|
|
|
*/
|
2005-02-03 07:39:32 +03:00
|
|
|
double significand(double);
|
1994-02-11 21:36:42 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Functions callable from C, intended to support IEEE arithmetic.
|
|
|
|
*/
|
2005-02-03 07:39:32 +03:00
|
|
|
double copysign(double, double);
|
|
|
|
double scalbn(double, int);
|
1994-02-11 21:36:42 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* BSD math library entry points
|
|
|
|
*/
|
2005-02-03 07:39:32 +03:00
|
|
|
double drem(double, double);
|
1994-02-11 21:36:42 +03:00
|
|
|
|
Add a new feature-test macro, _NETBSD_SOURCE. If this is defined
by the application, all NetBSD interfaces are made visible, even
if some other feature-test macro (like _POSIX_C_SOURCE) is defined.
<sys/featuretest.h> defined _NETBSD_SOURCE if none of _ANSI_SOURCE,
_POSIX_C_SOURCE and _XOPEN_SOURCE is defined, so as to preserve
existing behaviour.
This has two major advantages:
+ Programs that require non-POSIX facilities but define _POSIX_C_SOURCE
can trivially be overruled by putting -D_NETBSD_SOURCE in their CFLAGS.
+ It makes most of the #ifs simpler, in that they're all now ORs of the
various macros, rather than having checks for (!defined(_ANSI_SOURCE) ||
!defined(_POSIX_C_SOURCE) || !defined(_XOPEN_SOURCE)) all over the place.
I've tried not to change the semantics of the headers in any case where
_NETBSD_SOURCE wasn't defined, but there were some places where the
current semantics were clearly mad, and retaining them was harder than
correcting them. In particular, I've mostly normalised things so that
_ANSI_SOURCE gets you the smallest set of stuff, then _POSIX_C_SOURCE,
_XOPEN_SOURCE and _NETBSD_SOURCE in that order.
Tested by building for vax, encouraged by thorpej, and uncontested in
tech-userlevel for a week.
2003-04-29 03:16:11 +04:00
|
|
|
#endif /* _NETBSD_SOURCE */
|
1998-05-07 22:50:08 +04:00
|
|
|
|
Add a new feature-test macro, _NETBSD_SOURCE. If this is defined
by the application, all NetBSD interfaces are made visible, even
if some other feature-test macro (like _POSIX_C_SOURCE) is defined.
<sys/featuretest.h> defined _NETBSD_SOURCE if none of _ANSI_SOURCE,
_POSIX_C_SOURCE and _XOPEN_SOURCE is defined, so as to preserve
existing behaviour.
This has two major advantages:
+ Programs that require non-POSIX facilities but define _POSIX_C_SOURCE
can trivially be overruled by putting -D_NETBSD_SOURCE in their CFLAGS.
+ It makes most of the #ifs simpler, in that they're all now ORs of the
various macros, rather than having checks for (!defined(_ANSI_SOURCE) ||
!defined(_POSIX_C_SOURCE) || !defined(_XOPEN_SOURCE)) all over the place.
I've tried not to change the semantics of the headers in any case where
_NETBSD_SOURCE wasn't defined, but there were some places where the
current semantics were clearly mad, and retaining them was harder than
correcting them. In particular, I've mostly normalised things so that
_ANSI_SOURCE gets you the smallest set of stuff, then _POSIX_C_SOURCE,
_XOPEN_SOURCE and _NETBSD_SOURCE in that order.
Tested by building for vax, encouraged by thorpej, and uncontested in
tech-userlevel for a week.
2003-04-29 03:16:11 +04:00
|
|
|
#if defined(_NETBSD_SOURCE) || defined(_REENTRANT)
|
1994-02-11 21:36:42 +03:00
|
|
|
/*
|
|
|
|
* Reentrant version of gamma & lgamma; passes signgam back by reference
|
|
|
|
* as the second argument; user must allocate space for signgam.
|
|
|
|
*/
|
2005-02-03 07:39:32 +03:00
|
|
|
double gamma_r(double, int *);
|
|
|
|
double lgamma_r(double, int *);
|
Add a new feature-test macro, _NETBSD_SOURCE. If this is defined
by the application, all NetBSD interfaces are made visible, even
if some other feature-test macro (like _POSIX_C_SOURCE) is defined.
<sys/featuretest.h> defined _NETBSD_SOURCE if none of _ANSI_SOURCE,
_POSIX_C_SOURCE and _XOPEN_SOURCE is defined, so as to preserve
existing behaviour.
This has two major advantages:
+ Programs that require non-POSIX facilities but define _POSIX_C_SOURCE
can trivially be overruled by putting -D_NETBSD_SOURCE in their CFLAGS.
+ It makes most of the #ifs simpler, in that they're all now ORs of the
various macros, rather than having checks for (!defined(_ANSI_SOURCE) ||
!defined(_POSIX_C_SOURCE) || !defined(_XOPEN_SOURCE)) all over the place.
I've tried not to change the semantics of the headers in any case where
_NETBSD_SOURCE wasn't defined, but there were some places where the
current semantics were clearly mad, and retaining them was harder than
correcting them. In particular, I've mostly normalised things so that
_ANSI_SOURCE gets you the smallest set of stuff, then _POSIX_C_SOURCE,
_XOPEN_SOURCE and _NETBSD_SOURCE in that order.
Tested by building for vax, encouraged by thorpej, and uncontested in
tech-userlevel for a week.
2003-04-29 03:16:11 +04:00
|
|
|
#endif /* _NETBSD_SOURCE || _REENTRANT */
|
1994-08-11 00:48:16 +04:00
|
|
|
|
|
|
|
|
Add a new feature-test macro, _NETBSD_SOURCE. If this is defined
by the application, all NetBSD interfaces are made visible, even
if some other feature-test macro (like _POSIX_C_SOURCE) is defined.
<sys/featuretest.h> defined _NETBSD_SOURCE if none of _ANSI_SOURCE,
_POSIX_C_SOURCE and _XOPEN_SOURCE is defined, so as to preserve
existing behaviour.
This has two major advantages:
+ Programs that require non-POSIX facilities but define _POSIX_C_SOURCE
can trivially be overruled by putting -D_NETBSD_SOURCE in their CFLAGS.
+ It makes most of the #ifs simpler, in that they're all now ORs of the
various macros, rather than having checks for (!defined(_ANSI_SOURCE) ||
!defined(_POSIX_C_SOURCE) || !defined(_XOPEN_SOURCE)) all over the place.
I've tried not to change the semantics of the headers in any case where
_NETBSD_SOURCE wasn't defined, but there were some places where the
current semantics were clearly mad, and retaining them was harder than
correcting them. In particular, I've mostly normalised things so that
_ANSI_SOURCE gets you the smallest set of stuff, then _POSIX_C_SOURCE,
_XOPEN_SOURCE and _NETBSD_SOURCE in that order.
Tested by building for vax, encouraged by thorpej, and uncontested in
tech-userlevel for a week.
2003-04-29 03:16:11 +04:00
|
|
|
#if defined(_NETBSD_SOURCE)
|
1998-09-07 19:00:05 +04:00
|
|
|
|
1994-08-11 00:48:16 +04:00
|
|
|
/* float versions of ANSI/POSIX functions */
|
2000-06-13 05:21:52 +04:00
|
|
|
|
2005-02-03 07:39:32 +03:00
|
|
|
float gammaf(float);
|
|
|
|
int isinff(float);
|
|
|
|
int isnanf(float);
|
|
|
|
int finitef(float);
|
|
|
|
float j0f(float);
|
|
|
|
float j1f(float);
|
|
|
|
float jnf(int, float);
|
|
|
|
float y0f(float);
|
|
|
|
float y1f(float);
|
|
|
|
float ynf(int, float);
|
2000-06-13 05:21:52 +04:00
|
|
|
|
2005-02-03 07:39:32 +03:00
|
|
|
float scalbf(float, float);
|
1994-08-11 00:48:16 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* float version of IEEE Test Vector
|
|
|
|
*/
|
2005-02-03 07:39:32 +03:00
|
|
|
float significandf(float);
|
1994-08-11 00:48:16 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* float versions of BSD math library entry points
|
|
|
|
*/
|
2005-02-03 07:39:32 +03:00
|
|
|
float dremf(float, float);
|
Add a new feature-test macro, _NETBSD_SOURCE. If this is defined
by the application, all NetBSD interfaces are made visible, even
if some other feature-test macro (like _POSIX_C_SOURCE) is defined.
<sys/featuretest.h> defined _NETBSD_SOURCE if none of _ANSI_SOURCE,
_POSIX_C_SOURCE and _XOPEN_SOURCE is defined, so as to preserve
existing behaviour.
This has two major advantages:
+ Programs that require non-POSIX facilities but define _POSIX_C_SOURCE
can trivially be overruled by putting -D_NETBSD_SOURCE in their CFLAGS.
+ It makes most of the #ifs simpler, in that they're all now ORs of the
various macros, rather than having checks for (!defined(_ANSI_SOURCE) ||
!defined(_POSIX_C_SOURCE) || !defined(_XOPEN_SOURCE)) all over the place.
I've tried not to change the semantics of the headers in any case where
_NETBSD_SOURCE wasn't defined, but there were some places where the
current semantics were clearly mad, and retaining them was harder than
correcting them. In particular, I've mostly normalised things so that
_ANSI_SOURCE gets you the smallest set of stuff, then _POSIX_C_SOURCE,
_XOPEN_SOURCE and _NETBSD_SOURCE in that order.
Tested by building for vax, encouraged by thorpej, and uncontested in
tech-userlevel for a week.
2003-04-29 03:16:11 +04:00
|
|
|
#endif /* _NETBSD_SOURCE */
|
1994-08-11 00:48:16 +04:00
|
|
|
|
Add a new feature-test macro, _NETBSD_SOURCE. If this is defined
by the application, all NetBSD interfaces are made visible, even
if some other feature-test macro (like _POSIX_C_SOURCE) is defined.
<sys/featuretest.h> defined _NETBSD_SOURCE if none of _ANSI_SOURCE,
_POSIX_C_SOURCE and _XOPEN_SOURCE is defined, so as to preserve
existing behaviour.
This has two major advantages:
+ Programs that require non-POSIX facilities but define _POSIX_C_SOURCE
can trivially be overruled by putting -D_NETBSD_SOURCE in their CFLAGS.
+ It makes most of the #ifs simpler, in that they're all now ORs of the
various macros, rather than having checks for (!defined(_ANSI_SOURCE) ||
!defined(_POSIX_C_SOURCE) || !defined(_XOPEN_SOURCE)) all over the place.
I've tried not to change the semantics of the headers in any case where
_NETBSD_SOURCE wasn't defined, but there were some places where the
current semantics were clearly mad, and retaining them was harder than
correcting them. In particular, I've mostly normalised things so that
_ANSI_SOURCE gets you the smallest set of stuff, then _POSIX_C_SOURCE,
_XOPEN_SOURCE and _NETBSD_SOURCE in that order.
Tested by building for vax, encouraged by thorpej, and uncontested in
tech-userlevel for a week.
2003-04-29 03:16:11 +04:00
|
|
|
#if defined(_NETBSD_SOURCE) || defined(_REENTRANT)
|
1994-08-11 00:48:16 +04:00
|
|
|
/*
|
|
|
|
* Float versions of reentrant version of gamma & lgamma; passes
|
|
|
|
* signgam back by reference as the second argument; user must
|
|
|
|
* allocate space for signgam.
|
|
|
|
*/
|
2005-02-03 07:39:32 +03:00
|
|
|
float gammaf_r(float, int *);
|
|
|
|
float lgammaf_r(float, int *);
|
1998-05-07 22:50:08 +04:00
|
|
|
#endif /* !... || _REENTRANT */
|
1994-08-11 00:48:16 +04:00
|
|
|
|
2004-01-15 22:43:44 +03:00
|
|
|
/*
|
|
|
|
* Library implementation
|
|
|
|
*/
|
2005-02-03 07:39:32 +03:00
|
|
|
int __fpclassifyf(float);
|
|
|
|
int __fpclassifyd(double);
|
|
|
|
int __isfinitef(float);
|
|
|
|
int __isfinited(double);
|
|
|
|
int __isinff(float);
|
|
|
|
int __isinfd(double);
|
|
|
|
int __isnanf(float);
|
|
|
|
int __isnand(double);
|
|
|
|
int __signbitf(float);
|
|
|
|
int __signbitd(double);
|
2004-01-15 22:43:44 +03:00
|
|
|
|
|
|
|
#ifdef __HAVE_LONG_DOUBLE
|
2005-02-03 07:39:32 +03:00
|
|
|
int __fpclassifyl(long double);
|
|
|
|
int __isfinitel(long double);
|
|
|
|
int __isinfl(long double);
|
|
|
|
int __isnanl(long double);
|
|
|
|
int __signbitl(long double);
|
2004-01-15 22:43:44 +03:00
|
|
|
#endif
|
1993-03-21 12:45:37 +03:00
|
|
|
__END_DECLS
|
|
|
|
|
|
|
|
#endif /* _MATH_H_ */
|