os/ossrv/genericopenlibs/cstdlib/LINC/MATH.H
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 /*
     2 * Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8 *
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    11 *
    12 * Contributors:
    13 *
    14 * Description:
    15 *
    16 */
    17 
    18 
    19 
    20 /**
    21  @file
    22  @publishedAll
    23  @released
    24 */
    25 
    26 #ifndef  _MATH_H
    27 #ifdef __cplusplus
    28 extern "C" {
    29 #endif
    30 #define  _MATH_H
    31 
    32 #include <sys/reent.h>
    33 #include <libc/machine/ieeefp.h>
    34 #include <_ansi.h>
    35 
    36 void MapSymbianErrorCodeToErrno(int, int);
    37    
    38 /**
    39 Reentrant ANSI C functions
    40 */
    41 IMPORT_C double atan (double) __SOFTFP;
    42 IMPORT_C double cos (double) __SOFTFP;
    43 IMPORT_C double sin (double) __SOFTFP;
    44 IMPORT_C double tan (double) __SOFTFP;
    45 IMPORT_C double tanh (double) __SOFTFP;
    46 IMPORT_C double frexp (double, int *) __SOFTFP;
    47 IMPORT_C double modf (double, double *) __SOFTFP;
    48 IMPORT_C double ceil (double) __SOFTFP;
    49 IMPORT_C double fabs (double) __SOFTFP;
    50 IMPORT_C double floor (double) __SOFTFP;
    51 
    52 /**
    53 Non reentrant ANSI C functions.  
    54 */
    55 #ifndef _REENT_ONLY
    56 IMPORT_C double acos (double) __SOFTFP;
    57 IMPORT_C double asin (double) __SOFTFP;
    58 IMPORT_C double atan2 (double, double) __SOFTFP;
    59 IMPORT_C double cosh (double) __SOFTFP;
    60 IMPORT_C double sinh (double) __SOFTFP;
    61 IMPORT_C double exp (double) __SOFTFP;
    62 IMPORT_C double ldexp (double, int) __SOFTFP;
    63 IMPORT_C double log (double) __SOFTFP;
    64 IMPORT_C double log10 (double) __SOFTFP;
    65 IMPORT_C double pow (double, double) __SOFTFP;
    66 IMPORT_C double sqrt (double) __SOFTFP;
    67 IMPORT_C double fmod (double, double) __SOFTFP;
    68 #endif /* ! defined (_REENT_ONLY) */
    69 
    70 /**
    71 Non ANSI functions provided by EPOC32 
    72 */
    73 IMPORT_C double	copysign(double, double) __SOFTFP;
    74 IMPORT_C double	expm1	(double) __SOFTFP;
    75 IMPORT_C int	finite	(double) __SOFTFP;
    76 IMPORT_C int	isnan	(double) __SOFTFP;
    77 IMPORT_C int	isinf	(double) __SOFTFP;
    78 IMPORT_C double	rint	(double) __SOFTFP;
    79 IMPORT_C double	scalbn	(double, int) __SOFTFP;
    80 
    81 
    82 /**
    83 WARNING: For internal use ONLY. Compatibility is not guaranteed in future releases.
    84 strtod, atof, etc. may return HUGE_VAL 
    85 @internalComponent
    86 */
    87 #define	HUGE_VAL	1.7976931348623157E+308 /* KMaxTReal from e32math.h */
    88 
    89 
    90 #ifndef _STRICT_ANSI
    91 
    92 /**
    93 Non ANSI double precision functions.  
    94 */
    95 extern double infinity (void);
    96 extern double nan (void);
    97 extern int ilogb (double);
    98 
    99 extern double asinh (double);
   100 extern double cbrt (double);
   101 extern double nextafter (double, double);
   102 
   103 extern double log1p (double);
   104 
   105 #ifndef _REENT_ONLY
   106 extern double acosh (double);
   107 extern double atanh (double);
   108 extern double remainder (double, double);
   109 extern double gamma (double);
   110 extern double gamma_r (double, int *);
   111 extern double lgamma (double);
   112 extern double lgamma_r (double, int *);
   113 extern double erf (double);
   114 extern double erfc (double);
   115 extern double y0 (double);
   116 extern double y1 (double);
   117 extern double yn (int, double);
   118 extern double j0 (double);
   119 extern double j1 (double);
   120 extern double jn (int, double);
   121 #define log2(x) (log (x) / M_LOG2_E)
   122 
   123 extern double hypot (double, double);
   124 
   125 extern double cabs();
   126 extern double drem (double, double);
   127 
   128 #endif /* ! defined (_REENT_ONLY) */
   129 
   130 /**
   131 Single precision versions of ANSI functions.  
   132 */
   133 extern float atanf (float);
   134 extern float cosf (float);
   135 extern float sinf (float);
   136 extern float tanf (float);
   137 extern float tanhf (float);
   138 extern float frexpf (float, int *);
   139 extern float modff (float, float *);
   140 extern float ceilf (float);
   141 extern float fabsf (float);
   142 extern float floorf (float);
   143 
   144 #ifndef _REENT_ONLY
   145 extern float acosf (float);
   146 extern float asinf (float);
   147 extern float atan2f (float, float);
   148 extern float coshf (float);
   149 extern float sinhf (float);
   150 extern float expf (float);
   151 extern float ldexpf (float, int);
   152 extern float logf (float);
   153 extern float log10f (float);
   154 extern float powf (float, float);
   155 extern float sqrtf (float);
   156 extern float fmodf (float, float);
   157 #endif /* ! defined (_REENT_ONLY) */
   158 
   159 /**
   160 Other single precision functions.  
   161 */
   162 extern float infinityf (void);
   163 extern float nanf (void);
   164 extern int isnanf (float);
   165 extern int isinff (float);
   166 extern int finitef (float);
   167 extern float copysignf (float, float);
   168 extern int ilogbf (float);
   169 extern float asinhf (float);
   170 extern float cbrtf (float);
   171 extern float nextafterf (float, float);
   172 extern float rintf (float);
   173 extern float scalbnf (float, int);
   174 extern float log1pf (float);
   175 extern float expm1f (float);
   176 
   177 #ifndef _REENT_ONLY
   178 extern float acoshf (float);
   179 extern float atanhf (float);
   180 extern float remainderf (float, float);
   181 extern float gammaf (float);
   182 extern float gammaf_r (float, int *);
   183 extern float lgammaf (float);
   184 extern float lgammaf_r (float, int *);
   185 extern float erff (float);
   186 extern float erfcf (float);
   187 extern float y0f (float);
   188 extern float y1f (float);
   189 extern float ynf (int, float);
   190 extern float j0f (float);
   191 extern float j1f (float);
   192 extern float jnf (int, float);
   193 #define log2f(x) (logf (x) / (float) M_LOG2_E)
   194 extern float hypotf (float, float);
   195 extern float cabsf();
   196 extern float dremf (float, float);
   197 #endif /* ! defined (_REENT_ONLY) */
   198 
   199 /**
   200 The gamma functions use a global variable, signgam.
   201 */
   202 extern int signgam;
   203 
   204 /** 
   205 The exception structure passed to the matherr routine.  
   206 */
   207 struct exception 
   208 {
   209   int type;
   210   char *name;
   211   double arg1;
   212   double arg2;
   213   double retval;
   214   int err;
   215 };
   216 
   217 extern int matherr (struct exception *e);
   218 
   219 /**
   220 Values for the type field of struct exception.  
   221 */
   222 #define DOMAIN 1
   223 #define SING 2
   224 #define OVERFLOW 3
   225 #define UNDERFLOW 4
   226 #define TLOSS 5
   227 #define PLOSS 6
   228 
   229 /** 
   230 Useful constants.  
   231 */
   232 #define M_E		2.7182818284590452354
   233 #define M_LOG2E		1.4426950408889634074
   234 #define M_LOG10E	0.43429448190325182765
   235 #define M_LN2		0.69314718055994530942
   236 #define M_LN10		2.30258509299404568402
   237 #define M_PI		3.14159265358979323846
   238 #define M_TWOPI         (M_PI * 2.0)
   239 #define M_PI_2		1.57079632679489661923
   240 #define M_PI_4		0.78539816339744830962
   241 #define M_3PI_4		2.3561944901923448370E0
   242 #define M_SQRTPI        1.77245385090551602792981
   243 #define M_1_PI		0.31830988618379067154
   244 #define M_2_PI		0.63661977236758134308
   245 #define M_2_SQRTPI	1.12837916709551257390
   246 #define M_SQRT2		1.41421356237309504880
   247 #define M_SQRT1_2	0.70710678118654752440
   248 #define M_LN2LO         1.9082149292705877000E-10
   249 #define M_LN2HI         6.9314718036912381649E-1
   250 #define M_SQRT3   	1.73205080756887719000
   251 #define M_IVLN10        0.43429448190325182765 /* 1 / log(10) */
   252 #define M_LOG2_E        0.693147180559945309417
   253 #define M_INVLN2        1.4426950408889633870E0  /* 1 / log(2) */
   254 
   255 /**
   256 Global control over fdlibm error handling.  
   257 */
   258 enum __fdlibm_version
   259 {
   260   __fdlibm_ieee = -1,
   261   __fdlibm_svid,
   262   __fdlibm_xopen,
   263   __fdlibm_posix
   264 };
   265 
   266 #define _LIB_VERSION_TYPE enum __fdlibm_version
   267 #define _LIB_VERSION __fdlib_version
   268 
   269 extern _LIB_VERSION_TYPE _LIB_VERSION;
   270 
   271 #define _IEEE_  __fdlibm_ieee
   272 #define _SVID_  __fdlibm_svid
   273 #define _XOPEN_ __fdlibm_xopen
   274 #define _POSIX_ __fdlibm_posix
   275 
   276 #endif /* ! defined (_STRICT_ANSI) */
   277 
   278 #ifdef __cplusplus
   279 }
   280 #endif
   281 #endif /* _MATH_H */