X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=device%2Finclude%2Fmath.h;h=de015c35b4bd23705d6c084f4d846aa8b34e3bc8;hb=e36af71ea57b06119c27e0f81f91a70f9164f646;hp=326ab00e620a90845f57f54acf60cd1e7603c999;hpb=1071a6c6ae98b2f1017cc0bc323860ac0d145d8c;p=fw%2Fsdcc diff --git a/device/include/math.h b/device/include/math.h index 326ab00e..de015c35 100644 --- a/device/include/math.h +++ b/device/include/math.h @@ -1,6 +1,6 @@ /* math.h: Floating point math function declarations - Copyright (C) 2001 Jesus Calvino-Fraga, jesusc@ieee.org + Copyright (C) 2001 Jesus Calvino-Fraga, jesusc@ieee.org This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -21,6 +21,8 @@ #ifndef _INC_MATH #define _INC_MATH +#define HUGE_VALF 3.402823466e+38 + #define PI 3.1415926536 #define TWO_PI 6.2831853071 #define HALF_PI 1.5707963268 @@ -34,7 +36,6 @@ // EPS=2**(-12). Also define EPS2=EPS*EPS. #define EPS 244.14062E-6 #define EPS2 59.6046E-9 -#define XMAX 3.402823466E+38 union float_long { @@ -42,38 +43,54 @@ union float_long long l; }; +#if defined(SDCC_MATH_LIB) && defined(SDCC_mcs51) && !defined(SDCC_USE_XSTACK) && !defined(SDCC_STACK_AUTO) && !defined(_SDCC_NO_ASM_LIB_FUNCS) +// Compile the mcs51 assembly version only when all these +// conditions are met. Since not all the functions are +// reentrant, do not compile with --stack-auto is used. +#define MATH_ASM_MCS51 +#endif + + +/* Functions on the z80 & gbz80 are always reentrant and so the "reentrant" */ +/* keyword is not defined. */ +#if defined(SDCC_z80) || defined(SDCC_gbz80) +#define _FLOAT_FUNC_REENTRANT +#else +#define _FLOAT_FUNC_REENTRANT __reentrant +#endif + /********************************************** * Prototypes for float ANSI C math functions * **********************************************/ /* Trigonometric functions */ -float sinf(const float x); -float cosf(const float x); -float tanf(const float x); -float cotf(const float x); -float asinf(const float x); -float acosf(const float x); -float atanf(const float x); +float sinf(const float x) _FLOAT_FUNC_REENTRANT; +float cosf(const float x) _FLOAT_FUNC_REENTRANT; +float tanf(const float x) _FLOAT_FUNC_REENTRANT; +float cotf(const float x) _FLOAT_FUNC_REENTRANT; +float asinf(const float x) _FLOAT_FUNC_REENTRANT; +float acosf(const float x) _FLOAT_FUNC_REENTRANT; +float atanf(const float x) _FLOAT_FUNC_REENTRANT; float atan2f(const float x, const float y); /* Hyperbolic functions */ -float sinhf(const float x); -float coshf(const float x); -float tanhf(const float x); +float sinhf(const float x) _FLOAT_FUNC_REENTRANT; +float coshf(const float x) _FLOAT_FUNC_REENTRANT; +float tanhf(const float x) _FLOAT_FUNC_REENTRANT; /* Exponential, logarithmic and power functions */ float expf(const float x); -float logf(const float x); -float log10f(const float x); +float logf(const float x) _FLOAT_FUNC_REENTRANT; +float log10f(const float x) _FLOAT_FUNC_REENTRANT; float powf(const float x, const float y); -float sqrtf(const float a); +float sqrtf(const float a) _FLOAT_FUNC_REENTRANT; /* Nearest integer, absolute value, and remainder functions */ -float fabsf(const float x); +float fabsf(const float x) _FLOAT_FUNC_REENTRANT; float frexpf(const float x, int *pw2); float ldexpf(const float x, const int pw2); -float ceilf(float x); -float floorf(float x); +float ceilf(float x) _FLOAT_FUNC_REENTRANT; +float floorf(float x) _FLOAT_FUNC_REENTRANT; float modff(float x, float * y); #endif /* _INC_MATH */