-/*-------------------------------------------------------------------------
- float.h - ANSI functions forward declarations
+/* From MUSL */
- Copyright (C) 1998, Sandeep Dutta . sandeep.dutta@usa.net
+#ifndef _FLOAT_H
+#define _FLOAT_H
- This library is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; either version 2, or (at your option) any
- later version.
+#define FLT_RADIX 2
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
+#define FLT_MIN 1.17549435e-38F
+#define FLT_MAX 3.40282347e+38F
+#define FLT_EPSILON 1.19209290e-07F
- You should have received a copy of the GNU General Public License
- along with this library; see the file COPYING. If not, write to the
- Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
- MA 02110-1301, USA.
+#define FLT_MANT_DIG 24
+#define FLT_MIN_EXP (-125)
+#define FLT_MAX_EXP 128
- As a special exception, if you link this library with other files,
- some of which are compiled with SDCC, to produce an executable,
- this library does not by itself cause the resulting executable to
- be covered by the GNU General Public License. This exception does
- not however invalidate any other reasons why the executable file
- might be covered by the GNU General Public License.
--------------------------------------------------------------------------*/
+#define FLT_DIG 6
+#define FLT_MIN_10_EXP (-37)
+#define FLT_MAX_10_EXP 38
-#ifndef __FLOAT_H
-#define __FLOAT_H 1
+#define DBL_MIN 2.2250738585072014e-308
+#define DBL_MAX 1.7976931348623157e+308
+#define DBL_EPSILON 2.2204460492503131e-16
-#include <limits.h>
+#define DBL_MANT_DIG 53
+#define DBL_MIN_EXP (-1021)
+#define DBL_MAX_EXP 1024
-#define FLT_RADIX 2
-#define FLT_MANT_DIG 24
-#define FLT_EPSILON 1.192092896E-07F
-#define FLT_DIG 6
-#define FLT_MIN_EXP (-125)
-#define FLT_MIN 1.175494351E-38F
-#define FLT_MIN_10_EXP (-37)
-#define FLT_MAX_EXP (+128)
-#define FLT_MAX 3.402823466E+38F
-#define FLT_MAX_10_EXP (+38)
+#define DBL_DIG 15
+#define DBL_MIN_10_EXP (-307)
+#define DBL_MAX_10_EXP 308
-/* the following deal with IEEE single-precision numbers */
-#define EXCESS 126
-#define SIGNBIT ((unsigned long)0x80000000)
-#define __INFINITY ((unsigned long)0x7F800000)
-#define HIDDEN (unsigned long)(1ul << 23)
-#define SIGN(fp) (((unsigned long)(fp) >> (8*sizeof(fp)-1)) & 1)
-#define EXP(fp) (((unsigned long)(fp) >> 23) & (unsigned int) 0x00FF)
-#define MANT(fp) (((fp) & (unsigned long)0x007FFFFF) | HIDDEN)
-#define NORM 0xff000000
-#define PACK(s,e,m) ((s) | ((unsigned long)(e) << 23) | (m))
+#define FLT_ROUNDS 1 /* Check this */
-float __uchar2fs (unsigned char);
-float __schar2fs (signed char);
-float __uint2fs (unsigned int);
-float __sint2fs (signed int);
-float __ulong2fs (unsigned long);
-float __slong2fs (signed long);
-unsigned char __fs2uchar (float);
-signed char __fs2schar (float);
-unsigned int __fs2uint (float);
-signed int __fs2sint (float);
-unsigned long __fs2ulong (float);
-signed long __fs2slong (float);
+#if defined(__SDCC_z80) || defined(__SDCC_z180)
+#define FLT_EVAL_METHOD 0
+typedef float float_t;
+typedef double double_t;
+#else
+#define FLT_EVAL_METHOD -2
+typedef float float_t;
+typedef double double_t;
+#endif
-float __fsadd (float, float);
-float __fssub (float, float);
-float __fsmul (float, float);
-float __fsdiv (float, float);
-
-char __fslt (float, float);
-char __fseq (float, float);
-char __fsgt (float, float);
-
-#endif /* __SDC51_FLOAT_H */
+#endif
#ifndef _MATH_H
#define _MATH_H
-#ifndef double
+/* Large elements of this are drawn from MUSL */
-/* Compiler with full float/double support */
+extern int signgam;
-extern double fabs(double);
-extern double floor(double);
-extern double ceil(double);
-extern double modf(double, double *);
-extern double frexp(double, int *);
-extern double ldexp(double, int);
-extern double atof(char *);
+#ifndef double
-extern double sqrt(double);
+/* Compiler with full float/double support */
-extern double sin(double);
-extern double cos(double);
-extern double tan(double);
-extern double asin(double);
extern double acos(double);
+extern double asin(double);
extern double atan(double);
extern double atan2(double, double);
-extern double sinh(double);
+extern double atof(char *);
+extern double cbrt(double);
+extern double ceil(double);
+extern double copysign(double, double);
+extern double cos(double);
extern double cosh(double);
-extern double tanh(double);
-
+extern double erf(double);
+extern double exp(double);
+extern double expm1(double);
+extern double fabs(double);
+extern double fdim(double double);
+extern double floor(double);
+extern double fmax(double, double);
+extern double fmin(double, double);
+extern double fmod(double, double);
+extern double frexp(double, int *);
+extern double hypot(double, double);
+extern int ilogb(double);
+extern double j0(double);
+extern double j1(double);
+extern double jn(int, double);
+extern double ldexp(double, int);
+extern double lgamma(double);
+extern double lgamma_r, int *);
extern double log(double);
extern double log10(double);
extern double log1p(double);
extern double log2(double);
extern double logb(double);
-
+extern long lrint(double);
+extern long lround(double);
+extern double modf(double, double *);
extern double nan(const char *__tagp);
-
+extern double nearbyint(double);
+extern double nextafter(double, double);
extern double pow(double, double);
-extern double exp(double);
-
+extern double remainder(double, double);
+extern double remquo(double, double, int *);
+extern double rint(double);
+extern double round(double);
extern double scalbln(double, long);
extern double scalbn(double, int);
+extern double sin(double);
+extern double sinh(double);
+extern double sqrt(double);
+extern double tan(double);
+extern double tanh(double);
+extern double tgamma(double);
+extern double trunc(double);
+extern double y0(double);
+extern double y1(double);
+extern double yn(int, double);
+extern unsigned long __double_bits(double);
+extern int __fpclassify(double);
+extern int __signbit(double);
-extern double hypot(double, double);
+#define fpclassify(x) ( \
+ sizeof(x) == sizeof(float) ? __fpclassifyf(x) : \
+ __fpclassify(x))
+
+#define isinf(x) ( \
+ sizeof(x) == sizeof(float) ? (__float_bits(x) & 0x7fffffff) == 0x7f800000 : \
+ (__double_bits(x) & (__uint64_t)-1>>1) == (__uint64_t)0x7ff<<52)
+
+#define isnan(x) ( \
+ sizeof(x) == sizeof(float) ? (__float_bits(x) & 0x7fffffff) > 0x7f800000 : \
+ (__double_bits(x) & (__uint64_t)-1>>1) > (__uint64_t)0x7ff<<52)
+
+#define isnormal(x) ( \
+ sizeof(x) == sizeof(float) ? ((__float_bits(x)+0x00800000) & 0x7fffffff) >= 0x01000000 : \
+ ((__double_bits(x)+((__uint64_t)1<<52)) & (__uint64_t)-1>>1) >= (__uint64_t)1<<53)
+
+#define isfinite(x) ( \
+ sizeof(x) == sizeof(float) ? (__float_bits(x) & 0x7fffffff) < 0x7f800000 : \
+ (__double_bits(x) & (__uint64_t)-1>>1) < (__uint64_t)0x7ff<<52)
+
+#define signbit(x) ( \
+ sizeof(x) == sizeof(float) ? (int)(__float_bits(x)>>31) : \
+ (int)(__double_bits(x)>>63))
#else
/* We have double defined as float .. so fix up the support routines */
-#define fabs(a) fabsf(a)
-#define floor(a) floorf(a)
-#define ceil(a) ceilf(a)
-#define modf(a,b) modff(a,b)
-#define frexp(a,b) frexpf(a,b)
-#define ldexp(a,b) ldexpf(a,b)
+#define acos(a) acosf(a)
+#define asin(a) asinf(a)
+#define atan(a) atanf(a)
+#define atan2(a,b) atan2f(a,b)
/* FIXME atof equivalence */
-
-#define sqrt(a) sqrtf(a)
-
-#define sin(a) sinf(a)
-#define cos(a) cosf(a)
-#define tan(a) tanf(a)
-#define asin(a) asinf(a)
-#define acos(a) acosf(a)
-#define atan(a) atanf(a)
-#define atan2(a,b) atan2f(a,b)
-#define sinh(a) sinhf(a)
-#define cosh(a) coshf(a)
-#define tanh(a) tanhf(a)
-
+#define cbrt(a) cbrtf(a)
+#define ceil(a) ceilf(a)
+#define copysign(a,b) copysignf(a,b)
+#define cos(a) cosf(a)
+#define cosh(a) coshf(a)
+#define erf(a) erff(a)
+#define exp(a) expf(a)
+#define expm1(a) expm1f(a)
+#define fabs(a) fabsf(a)
+#define fdim(a,b) fdimf(a,b)
+#define floor(a) floorf(a)
+#define fmax(a,b) fmaxf(a,b)
+#define fmin(a,b) fminf(a,b)
+#define fmod(a,b) fmodf(a,b)
+#define frexp(a,b) frexpf(a,b)
+#define hypot(a,b) hypotf(a,b)
+#define ilogb(a) ilogbf(a)
+#define j0(a) j0f(a)
+#define j1(a) j1f(a)
+#define jn(a,b) jnf(a,b)
+#define ldexp(a,b) ldexpf(a,b)
+#define lgamma(a) lgammaf(a)
+#define lgamma_r(a,b) lgammaf_r(a,b)
#define log(a) logf(a)
#define log10(a) log10f(a)
#define log1p(a) log1pf(a)
#define log2(a) log2f(a)
#define logb(a) logbf(a)
-
+#define lrint(a) lrintf(a)
+#define lround(a) lroundf(a)
+#define modf(a,b) modff(a,b)
#define nan(a) nanf(a)
-
+#define nearbyint(a) nearbyintf(a)
+#define nextafter(a,b) nextafterf(a,b)
#define pow(a,b) powf(a,b)
-#define exp(a) expf(a)
-#define hypot(a,b) hypotf(a,b)
-
+#define remainder(a,b) remainderf(a,b)
+#define remquo(a,b,c) remquof(a,b,c)
+#define rint(a) rintf(a)
+#define round(a) roundf(a)
#define scalbln(a,b) scalblnf(a,b)
#define scalbn(a,b) scalblf(a,b)
+#define sin(a) sinf(a)
+#define sinh(a) sinhf(a)
+#define sqrt(a) sqrtf(a)
+#define tan(a) tanf(a)
+#define tanh(a) tanhf(a)
+#define tgamma(a) tgammaf(a)
+#define trunc(a) truncf(a)
+#define y0(a) y0f(a)
+#define y1(a) y1f(a)
+#define yn(a,b) ynf(a,b)
+
+#define fpclassify(x) __fpclassify(x))
+
+#define isinf(x) ( \
+ (__float_bits(x) & 0x7fffffff) == 0x7f800000)
+
+#define isnan(x) ( \
+ (__float_bits(x) & 0x7fffffff) > 0x7f800000)
+
+#define isnormal(x) ( \
+ ((__float_bits(x)+0x00800000) & 0x7fffffff) >= 0x0100000)
+
+#define isfinite(x) ( \
+ (__float_bits(x) & 0x7fffffff) < 0x7f800000)
+
+
+#define signbit(x) ( \
+ (int)(__float_bits(x)>>31))
#endif
extern float asinf(float);
extern float asinhf(float);
extern float atanf(float);
-extern float atan2f(float);
+extern float atan2f(float, float);
extern float atanhf(float);
+extern float cbrtf(float);
extern float ceilf(float);
+extern float copysignf(float, float);
+extern float cosf(float);
+extern float coshf(float);
+extern float erff(float);
+extern float expf(float);
+extern float expm1f(float);
extern float fabsf(float);
+extern float fdimf(float, float);
extern float floorf(float);
+extern float fmaxf(float, float);
+extern float fminf(float, float);
+extern float fmodf(float, float);
extern float frexpf(float, int *);
extern float hypotf(float, float);
+extern int ilogbf(float);
+extern float j0f(float);
+extern float j1f(float);
+extern float jnf(int, float);
+extern float ldexpf(float, int);
+extern float lgammaf(float);
+extern float lgammaf_r(float, int *);
extern float logf(float);
extern float log10f(float);
extern float log1pf(float);
extern float log2f(float);
extern float logbf(float);
+extern long lrintf(float);
+extern long lroundf(float);
+extern float modff(float, float *);
extern float nanf(const char *__tagp);
+extern float nearbyint(float);
+extern float nextafterf(float, float);
+extern float remainderf(float, float);
+extern float remquof(float, float, int *);
+extern float rintf(float);
+extern float roundf(float);
extern float scalblf(float, long);
extern float scalbnf(float, int);
+extern float sinf(float);
+extern float sinhf(float);
extern float sqrtf(float);
+extern float tgammaf(float);
+extern float trunc(float);
+extern float y0f(float);
+extern float y1f(float);
+extern float ynf(int, float);
+extern unsigned int __float_bits(float);
+extern int __fpclassifyf(float);
+extern int __signbitf(float);
/* FIXME: sort out the right NaN's */
#define __sNaN 0x1.fffff0p128
#define __FINFINITY 1e40f
+#define INFINITY __FINFINITY
+#define NAN __NaN
+
+#define M_E 2.7182818284590452354
+#define M_LOG2E 1.4426950408889634074
+#define M_LOG10E 0.43429448190325182765
+#define M_LN2 0.69314718055994530942
+#define M_LN10 2.30258509299404568402
+#define M_PI 3.14159265358979323846
+#define M_PI_2 1.57079632679489661923
+#define M_PI_4 0.78539816339744830962
+#define M_1_PI 0.31830988618379067154
+#define M_2_PI 0.63661977236758134308
+#define M_2_SQRTPI 1.12837916709551257390
+#define M_SQRT2 1.41421356237309504880
+#define M_SQRT_1_2 0.70710678118654752440
+
+#define HUGE 3.40282347e+38F
+#define HUGE_VALF INFINITY
+#define HUGE_VAL ((double)INFINITY)
+
+#define MAXFLOAT 3.40282347e+38F
+
+#define FP_NAN 0
+#define FP_INFINITE 1
+#define FP_ZERO 2
+#define FP_SUBNORMAL 3
+#define FP_NORMAL 4
+
+#define FP_ILOGBNAN (-1-(int)(((unsigned)-1)>>1))
+#define FP_ILOGB0 FP_ILOGBNAN
+
+
#endif