1 /*------------------------------------------------------------------------- 2 math.h: Floating point math function declarations 3 4 Copyright (C) 2001, Jesus Calvino-Fraga, jesusc@ieee.org 5 6 This library is free software; you can redistribute it and/or modify it 7 under the terms of the GNU General Public License as published by the 8 Free Software Foundation; either version 2, or (at your option) any 9 later version. 10 11 This library is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with this library; see the file COPYING. If not, write to the 18 Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 19 MA 02110-1301, USA. 20 21 As a special exception, if you link this library with other files, 22 some of which are compiled with SDCC, to produce an executable, 23 this library does not by itself cause the resulting executable to 24 be covered by the GNU General Public License. This exception does 25 not however invalidate any other reasons why the executable file 26 might be covered by the GNU General Public License. 27 -------------------------------------------------------------------------*/ 28 29 /* Version 1.0 - Initial release */ 30 31 #ifndef _INC_MATH 32 #define _INC_MATH 33 34 #define HUGE_VALF 3.402823466e+38 35 36 #define PI 3.1415926536 37 #define TWO_PI 6.2831853071 38 #define HALF_PI 1.5707963268 39 #define QUART_PI 0.7853981634 40 #define iPI 0.3183098862 41 #define iTWO_PI 0.1591549431 42 #define TWO_O_PI 0.6366197724 43 44 /* EPS=B**(-t/2), where B is the radix of the floating-point representation 45 and there are t base-B digits in the significand. Therefore, for floats 46 EPS=2**(-12). Also define EPS2=EPS*EPS. */ 47 #define EPS 244.14062E-6 48 #define EPS2 59.6046E-9 49 50 union float_long 51 { 52 float f; 53 long l; 54 }; 55 56 #if defined(__SDCC_MATH_LIB) && defined(__SDCC_mcs51) && !defined(__SDCC_USE_XSTACK) && !defined(__SDCC_STACK_AUTO) && !defined(_SDCC_NO_ASM_LIB_FUNCS) 57 /* Compile the mcs51 assembly version only when all these 58 conditions are met. Since not all the functions are 59 reentrant, do not compile with --stack-auto is used. */ 60 #define MATH_ASM_MCS51 61 #endif 62 63 64 /* Functions on the z80 & gbz80 are always reentrant and so the "reentrant" */ 65 /* keyword is not defined. */ 66 #if defined(__SDCC_z80) || defined(__SDCC_z180) || defined(__SDCC_r2k) || defined(__SDCC_r3ka) || defined(__SDCC_tlcs90) || defined(__SDCC_gbz80) || defined(__SDCC_ez80_z80) || defined(__SDCC_stm8) || defined(__SDCC_pic14) 67 #define _FLOAT_FUNC_REENTRANT 68 #else 69 #define _FLOAT_FUNC_REENTRANT __reentrant 70 #endif 71 72 /********************************************** 73 * Prototypes for float ANSI C math functions * 74 **********************************************/ 75 76 /* Trigonometric functions */ 77 float sinf(float x) _FLOAT_FUNC_REENTRANT; 78 float cosf(float x) _FLOAT_FUNC_REENTRANT; 79 float tanf(float x) _FLOAT_FUNC_REENTRANT; 80 float cotf(float x) _FLOAT_FUNC_REENTRANT; 81 float asinf(float x) _FLOAT_FUNC_REENTRANT; 82 float acosf(float x) _FLOAT_FUNC_REENTRANT; 83 float atanf(float x) _FLOAT_FUNC_REENTRANT; 84 float atan2f(float x, float y); 85 86 /* Hyperbolic functions */ 87 float sinhf(float x) _FLOAT_FUNC_REENTRANT; 88 float coshf(float x) _FLOAT_FUNC_REENTRANT; 89 float tanhf(float x) _FLOAT_FUNC_REENTRANT; 90 91 /* Exponential, logarithmic and power functions */ 92 float expf(float x) _FLOAT_FUNC_REENTRANT; 93 float logf(float x) _FLOAT_FUNC_REENTRANT; 94 float log10f(float x) _FLOAT_FUNC_REENTRANT; 95 float powf(float x, float y); 96 float sqrtf(float a) _FLOAT_FUNC_REENTRANT; 97 98 /* Nearest integer, absolute value, and remainder functions */ 99 float fabsf(float x) _FLOAT_FUNC_REENTRANT; 100 float frexpf(float x, int *pw2); 101 float ldexpf(float x, int pw2); 102 float ceilf(float x) _FLOAT_FUNC_REENTRANT; 103 float floorf(float x) _FLOAT_FUNC_REENTRANT; 104 float modff(float x, float * y); 105 106 int isnan(float f); 107 int isinf(float f); 108 #endif /* _INC_MATH */ 109