From c6c6780c8ee488461ffd0adbfdda60d1adce8c4e Mon Sep 17 00:00:00 2001 From: solar Date: Sun, 23 Nov 2003 18:34:55 +0000 Subject: [PATCH] Added missing float.h. Some touches. --- includes/float.h | 48 ++++++ includes/inttypes.h | 13 +- includes/math.h | 9 +- includes/stdlib.h | 32 ++-- includes/tgmath.h | 365 +------------------------------------------- 5 files changed, 70 insertions(+), 397 deletions(-) create mode 100644 includes/float.h diff --git a/includes/float.h b/includes/float.h new file mode 100644 index 0000000..a23f324 --- /dev/null +++ b/includes/float.h @@ -0,0 +1,48 @@ +// ---------------------------------------------------------------------------- +// $Id$ +// ---------------------------------------------------------------------------- +// Public Domain C Library - http://pdclib.sourceforge.net +// This code is Public Domain. Use, modify, and redistribute at will. +// ---------------------------------------------------------------------------- +// Characteristics of floating types +// ---------------------------------------------------------------------------- + +#ifndef __FLOAT_H +#define __FLOAT_H __FLOAT_H + +#define FLT_RADIX // TODO +#define FLT_ROUNDS // TODO +#define FLT_EVAL_METHOD // TODO +#define DECIMAL_DIG // TODO + +#define DBL_DIG // TODO +#define DBL_EPSILON // TODO +#define DBL_MANT_DIG // TODO +#define DBL_MAX // TODO +#define DBL_MAX_10_EXP // TODO +#define DBL_MAX_EXP // TODO +#define DBL_MIN // TODO +#define DBL_MIN_10_EXP // TODO +#define DBL_MIN_EXP // TODO + +#define FLT_DIG // TODO +#define FLT_EPSILON // TODO +#define FLT_MANT_DIG // TODO +#define FLT_MAX // TODO +#define FLT_MAX_10_EXP // TODO +#define FLT_MAX_EXP // TODO +#define FLT_MIN // TODO +#define FLT_MIN_10_EXP // TODO +#define FLT_MIN_EXP // TODO + +#define LDBL_DIG // TODO +#define LDBL_EPSILON // TODO +#define LDBL_MANT_DIG // TODO +#define LDBL_MAX // TODO +#define LDBL_MAX_10_EXP // TODO +#define LDBL_MAX_EXP // TODO +#define LDBL_MIN // TODO +#define LDBL_MIN_10_EXP // TODO +#define LDBL_MIN_EXP // TODO + +#endif // __FLOAT_H diff --git a/includes/inttypes.h b/includes/inttypes.h index bb52ea9..4f9f9ce 100644 --- a/includes/inttypes.h +++ b/includes/inttypes.h @@ -21,13 +21,18 @@ typedef struct imaxdiv_t; // ---------------------------------------------------------------------------- -// FUNCTIONS +// FUNCTIONS - C++ -intmax_t imaxabs( intmax_t i ); -intmax_t abs( intmax_t i ); [C++ only] +#ifdef __cplusplus +intmax_t abs( intmax_t i ); +imaxdiv_t div( intmax_t numer, intmax_t denom ); +#endif __cplusplus + +// ---------------------------------------------------------------------------- +// FUNCTIONS - Standard C +intmax_t imaxabs( intmax_t i ); imaxdiv_t imaxdiv( intmax_t numer, intmax_t denom ); -imaxdiv_t div( intmax_t numer, intmax_t denom ); [C++ only] intmax_t strtoimax( const char * restrict s, char * * restrict endptr, int base ); uintmax_t strtoumax( const char * restrict s, char * * restrict endptr, int base ); diff --git a/includes/math.h b/includes/math.h index c03037e..a3252b2 100644 --- a/includes/math.h +++ b/includes/math.h @@ -129,7 +129,6 @@ float asin( float x ); long double asin( long double x ); // These functions compute the arc hyperbolic sine of x. -// @returns arsinh x. float asinh( float x ); long double asinh( long double x ); @@ -343,7 +342,6 @@ float fabsf( float x ); long double fabsl( long double x ); // These functions compute the sine of x (measured in radians). -// @returns sin x. double sin( double x ); float sinf( float x ); long double sinl( long double x ); @@ -364,7 +362,6 @@ float asinhf( float x ); long double asinhl( long double x ); // These functions compute the cosine of x (measured in radians). -// @returns cos x. double cos( double x ); float cosf( float x ); long double cosl( long double x ); @@ -384,8 +381,7 @@ double acosh( double x ); float acoshf( float x ); long double acoshl( long double x ); -// These functions return the tangent of x (measured in radians). -// @returns tan x. +// These functions return the tangent of x. double tan( double x ); float tanf( float x ); long double tanl( long double x ); @@ -395,8 +391,7 @@ double tanh( double x ); float tanhf( float x ); long double tanhl( long double x ); -// These functions compute the principal value of the arc tangent of x. -// @returns arctan x in the interval [-p/2, +p/2] radians. +// These functions compute the arctangent of x. double atan( double x ); float atanf( float x ); long double atanl( long double x ); diff --git a/includes/stdlib.h b/includes/stdlib.h index 4518f22..c0efa68 100644 --- a/includes/stdlib.h +++ b/includes/stdlib.h @@ -56,21 +56,6 @@ long long abs( long long i ); ldiv_t div( long numer, long denom ); lldiv_t div( long long numer, long long denom ); -extern "C++" int atexit( void (*func) ( void ) ); -extern "C" int atexit( void (*func) ( void ) ); - -extern "C++" void * bsearch( const void * key, const void * base, - size_t nelem, size_t size, - int (*cmp) ( const void * ck, const void * ce ) ); -extern "C" void * bsearch( const void * key, const void * base, - size_t nelem, size_t size, - int (*cmp) ( const void * ck, const void * ce ) ); - -extern "C++" void qsort( void * base, size_t nelem, size_t size, - int (*cmp) ( const void * e1, const void * e2 ) ); -extern "C" void qsort( void * base, size_t nelem, size_t size, - int (*cmp) ( const void * e1, const void * e2 ) ); - #endif // __cplusplus // ---------------------------------------------------------------------------- @@ -119,14 +104,15 @@ void abort( void ); char * getenv( const char * name ); int system( const char * s ); -#ifndef __cplusplus - -int atexit( void (*func) ( void ) ); -void * bsearch( const void * key, const void * base, size_t nelem, size_t size, - int (*cmp) ( const void * ck, const void * ce) ); -void qsort( void * base, size_t nelem, size_t size, - int (*cmp) ( const void * e1, const void * e2) ); - +#ifdef __cplusplus +#define __cppwrapper( x ) extern "C++" x \ +extern "C" x +#else +#define __cppwrapper( x ) x #endif // __cplusplus +__cppwrapper( int atexit( void (*func) ( void ) ) { /* TODO */ }; ) +__cppwrapper( void * bsearch( const void * key, const void * base, size_t nelem, size_t size, int (*cmp) ( const void * ck, const void * ce) ) { /* TODO */ }; ) +__cppwrapper( void qsort( void * base, size_t nelem, size_t size, int (*cmp) ( const void * e1, const void * e2) ) { /* TODO */ }; ) + #endif // __STDLIB_H diff --git a/includes/tgmath.h b/includes/tgmath.h index c356272..503107d 100644 --- a/includes/tgmath.h +++ b/includes/tgmath.h @@ -10,368 +10,7 @@ #ifndef __TGMATH_H #define __TGMATH_H __TGMATH_H -// These functions return the sine of their parameter. -double sin(double value); -float sin(float value); -long double sin(long double value); -double _Complex sin(double _Complex value); -float _Complex sin(float _Complex value); -long double _Complex sin(long double _Complex value); - -// These functions return the hyperbolic sine of their parameter. -double sinh(double value); -float sinh(float value); -long double sinh(long double value); -double _Complex sinh(double _Complex value); -float _Complex sinh(float _Complex value); -long double _Complex sinh(long double _Complex value); - -// These functions return the arcsine of their parameter. -double asin(double value); -float asin(float value); -long double asin(long double value); -double _Complex asin(double _Complex value); -float _Complex asin(float _Complex value); -long double _Complex asin(long double _Complex value); - -// These functions return the hyperbolic arcsine of their parameter. -double asinh(double value); -float asinh(float value); -long double asinh(long double value); -double _Complex asinh(double _Complex value); -float _Complex asinh(float _Complex value); -long double _Complex asinh(long double _Complex value); - -// These functions return the cosine of their parameter. -double cos(double value); -float cos(float value); -long double cos(long double value); -double _Complex cos(double _Complex value); -float _Complex cos(float _Complex value); -long double _Complex cos(long double _Complex value); - -// These functions return the hyperbolic cosine of their parameter. -double cosh(double value); -float cosh(float value); -long double cosh(long double value); -double _Complex cosh(double _Complex value); -float _Complex cosh(float _Complex value); -long double _Complex cosh(long double _Complex value); - -// These functions return the arccosine of their parameter. -double acos(double value); -float acos(float value); -long double acos(long double value); -double _Complex acos(double _Complex value); -float _Complex acos(float _Complex value); -long double _Complex acos(long double _Complex value); - -// These functions return the hyperbolic arccosine of their parameter. -double acosh(double value); -float acosh(float value); -long double acosh(long double value); -double _Complex acosh(double _Complex value); -float _Complex acosh(float _Complex value); -long double _Complex acosh(long double _Complex value); - -// These functions return the tangent of their parameter. -double tan(double value); -float tan(float value); -long double tan(long double value); -double _Complex tan(double _Complex value); -float _Complex tan(float _Complex value); -long double _Complex tan(long double _Complex value); - -// These functions return the hyperbolic tangent of their parameter. -double tanh(double value); -float tanh(float value); -long double tanh(long double value); -double _Complex tanh(double _Complex value); -float _Complex tanh(float _Complex value); -long double _Complex tanh(long double _Complex value); - -// These functions return the arctangent of their parameter. -double atan(double value); -float atan(float value); -long double atan(long double value); -double _Complex atan(double _Complex value); -float _Complex atan(float _Complex value); -long double _Complex atan(long double _Complex value); - -// These functions return the hyperbolic arctangent of their parameter. -double atanh(double value); -float atanh(float value); -long double atanh(long double value); -double _Complex atanh(double _Complex value); -float _Complex atanh(float _Complex value); -long double _Complex atanh(long double _Complex value); - -// These functions return the angle whose tangent is x / y. -double atan2(double x, double y); -float atan2(float x, float y); -long double atan2(long double x, long double y); - -// These functions return the phase angle of their parameter. -double carg(double _Complex value); -float carg(float _Complex value); -long double carg(long double _Complex value); - -// These functions return the largest integer no larger than their parameter. -double floor(double value); -float floor(float value); -long double floor(long double value); - -// These functions return the smallest integer not less than their parameter. -double ceil(double value); -float ceil(float value); -long double ceil(long double value); - -// These functions return the square root of their parameter. -double sqrt(double value); -float sqrt(float value); -long double sqrt(long double value); -double _Complex sqrt(double _Complex value); -float _Complex sqrt(float _Complex value); -long double _Complex sqrt(long double _Complex value); - -// These functions return the cube root of their parameter. -double cbrt(double value); -float cbrt(float value); -long double cbrt(long double value); - -// These functions return the imaginary part of their parameter. -double cimag(double _Complex value); -float cimag(float _Complex value); -long double cimag(long double _Complex value); - -// These functions return the real value of their parameter. -double creal(double _Complex value); -float creal(float _Complex value); -long double creal(long double _Complex value); - -// These functions return the conjugate of their parameter. -double _Complex conj(double _Complex value); -float _Complex conj(float _Complex value); -long double _Complex conj(long double _Complex value); - -// These functions return their parameter x with the sign of y. -double copysign(double x, double y); -float copysign(float x, float y); -long double copysign(long double x, long double y); - -// These functions return the projection of their parameter. -double _Complex cproj(double _Complex value); -float _Complex cproj(float _Complex value); -long double _Complex cproj(long double _Complex value); - -// These functions return the error function of their parameter. -double erf(double value); -float erf(float value); -long double erf(long double value); - -// These functions return the complementary error function of their parameter. -double erfc(double value); -float erfc(float value); -long double erfc(long double value); - -// These functions return the exponential of their parameter (e^x). -double exp(double value); -float exp(float value); -long double exp(long double value); -double _Complex exp(double _Complex value); -float _Complex exp(float _Complex value); -long double _Complex exp(long double _Complex value); - -// These functions return 2 raised to the power of their parameter (2^x). -double exp2(double value); -float exp2(float value); -long double exp2(long double value); - -// These functions return exp(value) - 1. -double expm1(double value); -float expm1(float value); -long double expm1(long double value); - -// These functions return the magnitude of their parameter. -double fabs(double value); -float fabs(float value); -long double fabs(long double value); -double fabs(double _Complex value); -float fabs(float _Complex value); -long double fabs(long double _Complex value); - -// These functions return the larger of (x-y) and zero. -double fdim(double x, double y); -float fdim(float x, float y); -long double fdim(long double x, long double y); - -// These functions return (x * y + z) to arbitrary intermediate precision. -double fma(double x, double y, double z); -float fma(float x, float y, float z); -long double fma(long double x, long double y, long double z); - -// These functions return the larger of their parameters. -double fmax(double x, double y); -float fmax(float x, float y); -long double fmax(long double x, long double y); - -// These functions return the smaller of their parameters. -double fmin(double x, double y); -float fmin(float x, float y); -long double fmin(long double x, long double y); - -// These functions return the remainder of (x/y). -double fmod(double x, double y); -float fmod(float x, float y); -long double fmod(long double x, long double y); - -// These functions return a fraction (as return value) and an integer -// exponent (in the parameter 'exponent') that represent value, with the -// fraction being in the interval [0.5, 1) or being zero. If value is zero, -// exponent will also be zero. -// (fraction * 2^exponent) == value) -double frexp(double value, int * exponent); -float frexp(float value, int * exponent); -long double frexp(long double value, int * exponent); - -// These functions return x raised to the power of y. -double pow(double x, double y); -float pow(float x, float y); -long double pow(long double x, long double y); -double _Complex pow(double _Complex x, double _Complex y); -float _Complex pow(float _Complex x, float _Complex y); -long double _Complex pow(long double _Complex x, long double _Complex y); - -// TODO: Check spelling of hypothenuse and cathedes. -// These functions determine the length of the hypothenuse for the cathedes -// x and y. (Square root of a^2 + b^2.) -double hypot(double a, double b); -float hypot(float a, float b); -long double hypot(long double a, long double b); - -// These functions return (int) logb(value). -int ilogb(double value); -int ilogb(float value); -int ilogb(long double value); - -// These functions return (value * 2^exponent). -double ldexp(double value, int exponent); -float ldexp(float value, int exponent); -long double ldexp(long double value, int exponent); - -// These functions return the natural logarithm of their parameter. -double log(double value); -float log(float value); -long double log(long double value); -double _Complex log(double _Complex value); -float _Complex log(float _Complex value); -long double _Complex log(long double _Complex value); - -// These functions return the logarithm (base 10) of their parameter. -double log10(double value); -float log10(float value); -long double log10(long double value); - -// These functions return the natural logarithm of (their parameter + 1). -double log1p(double value); -float log1p(float value); -long double log1p(long double value); - -// These functions return the logarithm (base 2) of their parameter. -double log2(double value); -float log2(float value); -long double log2(long double value); - -// TODO: What do these functions actually do? -double logb(double value); -float logb(float value); -long double logb(long double value); - -// These functions return their parameter rounded to the next integer, using -// the current rounding mode. -long long llrint(double value); -long long llrint(float value); -long long llrint(long double value); -long lrint(double value); -long lrint(float value); -long lrint(long double value); -double rint(double value); -float rint(float value); -long double rint(long double value); - -// These functions return their parameter rounded to the next integer, with -// halfway values rounded away from zero regardless of current rounding mode. -long long llround(double value); -long long llround(float value); -long long llround(long double value); -long lround(double value); -long lround(float value); -long lround(long double value); -// TODO: Do the round() functions really return FP values? -double round(double value); -float round(float value); -long double round(long double value); - -// These functions return their parameter, rounded toward zero. -// TODO: Do these functions really return FP values? -double trunc(double value); -float trunc(float value); -long double trunc(long double value); - -// These functions store the integer part of value in integer, and return the -// remaining part of value. -double modf(double value, double * integer); -float modf(float value, float * integer); -long double modf(long double value, long double * integer); - -// These functions return their parameter rounded to the next integer, using -// the current rounding mode but without raising an inexact FP exception. -double nearbyint(double value); -float nearbyint(float value); -long double nearbyint(long double value); - -// These functions return the next representable value after the smaller of -// their parameters. -// TODO: This might be a wrong description. -double nextafter(double x, double y); -float nextafter(float x, float y); -long double nextafter(long double x, long double y); - -// These functions return the next representable value after the smaller of -// their parameters. -// TODO: This might be a wrong description. -double nexttoward(double x, long double y); -float nexttoward(float x, long double y); -long double nexttoward(long double x, long double y); - -// TODO -double remainder(double x, double y); -float remainder(float x, float y); -long double remainder(long double x, long double y); - -// TODO -double remquo(double x, double y, int * pquo); -float remquo(float x, float y, int * pquo); -long double remquo(long double x, long double y, int * pquo); - -// TODO -double scalbln(double x, long ex); -float scalbln(float x, long ex); -long double scalbln(long double x, long ex); - -// TODO -double scalbn(double x, int ex); -float scalbn(float x, int ex); -long double scalbn(long double x, int ex); - -// These functions return the gamma function of their parameter. -double tgamma(double value); -float tgamma(float value); -long double tgamma(long double value); - -// These functions return log( fabs( tgamma(value) ) ). -double lgamma(double value); -float lgamma(float value); -long double lgamma(long double value); +#include +#include #endif // __TGMATH_H -- 2.40.0