#ifndef CYGONCE_LIBM_MATHINCL_FDLIBM_H
|
#ifndef CYGONCE_LIBM_MATHINCL_FDLIBM_H
|
#define CYGONCE_LIBM_MATHINCL_FDLIBM_H
|
#define CYGONCE_LIBM_MATHINCL_FDLIBM_H
|
//===========================================================================
|
//===========================================================================
|
//
|
//
|
// fdlibm.h
|
// fdlibm.h
|
//
|
//
|
// Internal definitions for math library implementation based on fdlibm
|
// Internal definitions for math library implementation based on fdlibm
|
//
|
//
|
//===========================================================================
|
//===========================================================================
|
//####ECOSGPLCOPYRIGHTBEGIN####
|
//####ECOSGPLCOPYRIGHTBEGIN####
|
// -------------------------------------------
|
// -------------------------------------------
|
// This file is part of eCos, the Embedded Configurable Operating System.
|
// This file is part of eCos, the Embedded Configurable Operating System.
|
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
|
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
|
//
|
//
|
// eCos is free software; you can redistribute it and/or modify it under
|
// eCos 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
|
// 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.
|
// Software Foundation; either version 2 or (at your option) any later version.
|
//
|
//
|
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
|
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
// for more details.
|
// for more details.
|
//
|
//
|
// You should have received a copy of the GNU General Public License along
|
// You should have received a copy of the GNU General Public License along
|
// with eCos; if not, write to the Free Software Foundation, Inc.,
|
// with eCos; if not, write to the Free Software Foundation, Inc.,
|
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
//
|
//
|
// As a special exception, if other files instantiate templates or use macros
|
// As a special exception, if other files instantiate templates or use macros
|
// or inline functions from this file, or you compile this file and link it
|
// or inline functions from this file, or you compile this file and link it
|
// with other works to produce a work based on this file, this file does not
|
// with other works to produce a work based on this file, this file does not
|
// by itself cause the resulting work to be covered by the GNU General Public
|
// by itself cause the resulting work to be covered by the GNU General Public
|
// License. However the source code for this file must still be made available
|
// License. However the source code for this file must still be made available
|
// in accordance with section (3) of the GNU General Public License.
|
// in accordance with section (3) of the GNU General Public License.
|
//
|
//
|
// This exception does not invalidate any other reasons why a work based on
|
// This exception does not invalidate any other reasons why a work based on
|
// this file might be covered by the GNU General Public License.
|
// this file might be covered by the GNU General Public License.
|
//
|
//
|
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
|
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
|
// at http://sources.redhat.com/ecos/ecos-license/
|
// at http://sources.redhat.com/ecos/ecos-license/
|
// -------------------------------------------
|
// -------------------------------------------
|
//####ECOSGPLCOPYRIGHTEND####
|
//####ECOSGPLCOPYRIGHTEND####
|
//===========================================================================
|
//===========================================================================
|
//#####DESCRIPTIONBEGIN####
|
//#####DESCRIPTIONBEGIN####
|
//
|
//
|
// Author(s): jlarmour
|
// Author(s): jlarmour
|
// Contributors: jlarmour
|
// Contributors: jlarmour
|
// Date: 1999-02-09
|
// Date: 1999-02-09
|
// Purpose:
|
// Purpose:
|
// Description: Internal implementation-specific header for math library
|
// Description: Internal implementation-specific header for math library
|
// based on fdlibm
|
// based on fdlibm
|
// Usage: From within this package, #include "mathincl/fdlibm.h"
|
// Usage: From within this package, #include "mathincl/fdlibm.h"
|
//
|
//
|
//####DESCRIPTIONEND####
|
//####DESCRIPTIONEND####
|
//
|
//
|
//===========================================================================
|
//===========================================================================
|
|
|
// CONFIGURATION
|
// CONFIGURATION
|
|
|
#include <pkgconf/libm.h> // Configuration header
|
#include <pkgconf/libm.h> // Configuration header
|
|
|
// Include the Math library?
|
// Include the Math library?
|
#ifdef CYGPKG_LIBM
|
#ifdef CYGPKG_LIBM
|
|
|
// INCLUDES
|
// INCLUDES
|
|
|
#include <cyg/infra/cyg_type.h> // Common type definitions and support
|
#include <cyg/infra/cyg_type.h> // Common type definitions and support
|
#include <math.h> // Main header for math library
|
#include <math.h> // Main header for math library
|
#include <float.h> // Properties of FP representation on this
|
#include <float.h> // Properties of FP representation on this
|
// platform
|
// platform
|
|
|
// SANITY CHECKS
|
// SANITY CHECKS
|
|
|
// Just check that we support IEEE-style 64-bit doubles. If not, this
|
// Just check that we support IEEE-style 64-bit doubles. If not, this
|
// math library will not work
|
// math library will not work
|
// This check will go away when support for single-precision alternatives are
|
// This check will go away when support for single-precision alternatives are
|
// provided
|
// provided
|
|
|
#if DBL_MAX_EXP != 1024
|
#if DBL_MAX_EXP != 1024
|
# error IEEE-style 64-bit doubles are required to use the math library
|
# error IEEE-style 64-bit doubles are required to use the math library
|
#endif // if DBL_MAX_EXP == 1024
|
#endif // if DBL_MAX_EXP == 1024
|
|
|
|
|
// TYPES
|
// TYPES
|
|
|
typedef cyg_int32 __int32_t;
|
typedef cyg_int32 __int32_t;
|
typedef cyg_uint32 __uint32_t;
|
typedef cyg_uint32 __uint32_t;
|
typedef Cyg_libm_ieee_double_shape_type ieee_double_shape_type;
|
typedef Cyg_libm_ieee_double_shape_type ieee_double_shape_type;
|
|
|
// MACRO DEFINITIONS
|
// MACRO DEFINITIONS
|
|
|
#ifndef __STDC__
|
#ifndef __STDC__
|
# define __STDC__ 1
|
# define __STDC__ 1
|
#endif
|
#endif
|
#define CYG_LIBM_HI(__x) (((Cyg_libm_ieee_double_shape_type *)&__x)->parts.msw)
|
#define CYG_LIBM_HI(__x) (((Cyg_libm_ieee_double_shape_type *)&__x)->parts.msw)
|
#define CYG_LIBM_LO(__x) (((Cyg_libm_ieee_double_shape_type *)&__x)->parts.lsw)
|
#define CYG_LIBM_LO(__x) (((Cyg_libm_ieee_double_shape_type *)&__x)->parts.lsw)
|
#define CYG_LIBM_HIp(__x) (((Cyg_libm_ieee_double_shape_type *)__x)->parts.msw)
|
#define CYG_LIBM_HIp(__x) (((Cyg_libm_ieee_double_shape_type *)__x)->parts.msw)
|
#define CYG_LIBM_LOp(__x) (((Cyg_libm_ieee_double_shape_type *)__x)->parts.lsw)
|
#define CYG_LIBM_LOp(__x) (((Cyg_libm_ieee_double_shape_type *)__x)->parts.lsw)
|
|
|
|
|
|
|
/* Get two 32 bit ints from a double. */
|
/* Get two 32 bit ints from a double. */
|
|
|
#define EXTRACT_WORDS(ix0,ix1,d) \
|
#define EXTRACT_WORDS(ix0,ix1,d) \
|
do { \
|
do { \
|
Cyg_libm_ieee_double_shape_type ew_u; \
|
Cyg_libm_ieee_double_shape_type ew_u; \
|
ew_u.value = (d); \
|
ew_u.value = (d); \
|
(ix0) = ew_u.parts.msw; \
|
(ix0) = ew_u.parts.msw; \
|
(ix1) = ew_u.parts.lsw; \
|
(ix1) = ew_u.parts.lsw; \
|
} while (0)
|
} while (0)
|
|
|
/* Get the more significant 32 bit int from a double. */
|
/* Get the more significant 32 bit int from a double. */
|
|
|
#define GET_HIGH_WORD(i,d) \
|
#define GET_HIGH_WORD(i,d) \
|
do { \
|
do { \
|
Cyg_libm_ieee_double_shape_type gh_u; \
|
Cyg_libm_ieee_double_shape_type gh_u; \
|
gh_u.value = (d); \
|
gh_u.value = (d); \
|
(i) = gh_u.parts.msw; \
|
(i) = gh_u.parts.msw; \
|
} while (0)
|
} while (0)
|
|
|
/* Get the less significant 32 bit int from a double. */
|
/* Get the less significant 32 bit int from a double. */
|
|
|
#define GET_LOW_WORD(i,d) \
|
#define GET_LOW_WORD(i,d) \
|
do { \
|
do { \
|
Cyg_libm_ieee_double_shape_type gl_u; \
|
Cyg_libm_ieee_double_shape_type gl_u; \
|
gl_u.value = (d); \
|
gl_u.value = (d); \
|
(i) = gl_u.parts.lsw; \
|
(i) = gl_u.parts.lsw; \
|
} while (0)
|
} while (0)
|
|
|
/* Set a double from two 32 bit ints. */
|
/* Set a double from two 32 bit ints. */
|
|
|
#define INSERT_WORDS(d,ix0,ix1) \
|
#define INSERT_WORDS(d,ix0,ix1) \
|
do { \
|
do { \
|
Cyg_libm_ieee_double_shape_type iw_u; \
|
Cyg_libm_ieee_double_shape_type iw_u; \
|
iw_u.parts.msw = (ix0); \
|
iw_u.parts.msw = (ix0); \
|
iw_u.parts.lsw = (ix1); \
|
iw_u.parts.lsw = (ix1); \
|
(d) = iw_u.value; \
|
(d) = iw_u.value; \
|
} while (0)
|
} while (0)
|
|
|
/* Set the more significant 32 bits of a double from an int. */
|
/* Set the more significant 32 bits of a double from an int. */
|
|
|
#define SET_HIGH_WORD(d,v) \
|
#define SET_HIGH_WORD(d,v) \
|
do { \
|
do { \
|
Cyg_libm_ieee_double_shape_type sh_u; \
|
Cyg_libm_ieee_double_shape_type sh_u; \
|
sh_u.value = (d); \
|
sh_u.value = (d); \
|
sh_u.parts.msw = (v); \
|
sh_u.parts.msw = (v); \
|
(d) = sh_u.value; \
|
(d) = sh_u.value; \
|
} while (0)
|
} while (0)
|
|
|
/* Set the less significant 32 bits of a double from an int. */
|
/* Set the less significant 32 bits of a double from an int. */
|
|
|
#define SET_LOW_WORD(d,v) \
|
#define SET_LOW_WORD(d,v) \
|
do { \
|
do { \
|
Cyg_libm_ieee_double_shape_type sl_u; \
|
Cyg_libm_ieee_double_shape_type sl_u; \
|
sl_u.value = (d); \
|
sl_u.value = (d); \
|
sl_u.parts.lsw = (v); \
|
sl_u.parts.lsw = (v); \
|
(d) = sl_u.value; \
|
(d) = sl_u.value; \
|
} while (0)
|
} while (0)
|
|
|
|
|
// REPLACEMENTS FOR STUFF FROM MATH.H DUE TO CONFIG OPTION
|
// REPLACEMENTS FOR STUFF FROM MATH.H DUE TO CONFIG OPTION
|
|
|
#ifdef CYGSYM_LIBM_NO_XOPEN_SVID_NAMESPACE_POLLUTION
|
#ifdef CYGSYM_LIBM_NO_XOPEN_SVID_NAMESPACE_POLLUTION
|
|
|
#define HUGE FLT_MAX // from float.h
|
#define HUGE FLT_MAX // from float.h
|
#define DOMAIN 1
|
#define DOMAIN 1
|
#define SING 2
|
#define SING 2
|
#define OVERFLOW 3
|
#define OVERFLOW 3
|
#define UNDERFLOW 4
|
#define UNDERFLOW 4
|
#define TLOSS 5
|
#define TLOSS 5
|
#define PLOSS 6
|
#define PLOSS 6
|
|
|
struct exception {
|
struct exception {
|
int type; // One of DOMAIN, SING, OVERFLOW, UNDERFLOW, TLOSS, PLOSS
|
int type; // One of DOMAIN, SING, OVERFLOW, UNDERFLOW, TLOSS, PLOSS
|
char *name; // Name of the function generating the exception
|
char *name; // Name of the function generating the exception
|
double arg1; // First argument to the function
|
double arg1; // First argument to the function
|
double arg2; // Second argument to the function
|
double arg2; // Second argument to the function
|
double retval; // Value to be returned - can be altered by matherr()
|
double retval; // Value to be returned - can be altered by matherr()
|
};
|
};
|
|
|
externC int
|
externC int
|
matherr( struct exception * ); // User-overridable error handling - see
|
matherr( struct exception * ); // User-overridable error handling - see
|
// <pkgconf/libm.h> for a discussion
|
// <pkgconf/libm.h> for a discussion
|
#endif // ifdef CYGSYM_LIBM_NO_XOPEN_SVID_NAMESPACE_POLLUTION
|
#endif // ifdef CYGSYM_LIBM_NO_XOPEN_SVID_NAMESPACE_POLLUTION
|
|
|
|
|
// FUNCTION PROTOTYPES
|
// FUNCTION PROTOTYPES
|
|
|
// IEEE-754 style elementary functions */
|
// IEEE-754 style elementary functions */
|
|
|
externC double
|
externC double
|
__ieee754_sqrt( double );
|
__ieee754_sqrt( double );
|
|
|
externC double
|
externC double
|
__ieee754_acos( double );
|
__ieee754_acos( double );
|
|
|
externC double
|
externC double
|
__ieee754_acosh( double );
|
__ieee754_acosh( double );
|
|
|
externC double
|
externC double
|
__ieee754_log( double );
|
__ieee754_log( double );
|
|
|
externC double
|
externC double
|
__ieee754_atanh( double );
|
__ieee754_atanh( double );
|
|
|
externC double
|
externC double
|
__ieee754_asin( double );
|
__ieee754_asin( double );
|
|
|
externC double
|
externC double
|
__ieee754_atan2( double, double );
|
__ieee754_atan2( double, double );
|
|
|
externC double
|
externC double
|
__ieee754_exp( double );
|
__ieee754_exp( double );
|
|
|
externC double
|
externC double
|
__ieee754_cosh( double );
|
__ieee754_cosh( double );
|
|
|
externC double
|
externC double
|
__ieee754_fmod( double, double );
|
__ieee754_fmod( double, double );
|
|
|
externC double
|
externC double
|
__ieee754_pow( double, double );
|
__ieee754_pow( double, double );
|
|
|
externC double
|
externC double
|
__ieee754_lgamma_r( double, int * );
|
__ieee754_lgamma_r( double, int * );
|
|
|
externC double
|
externC double
|
__ieee754_gamma_r( double, int * );
|
__ieee754_gamma_r( double, int * );
|
|
|
externC double
|
externC double
|
__ieee754_lgamma( double );
|
__ieee754_lgamma( double );
|
|
|
externC double
|
externC double
|
__ieee754_gamma( double );
|
__ieee754_gamma( double );
|
|
|
externC double
|
externC double
|
__ieee754_log10( double );
|
__ieee754_log10( double );
|
|
|
externC double
|
externC double
|
__ieee754_sinh( double );
|
__ieee754_sinh( double );
|
|
|
externC double
|
externC double
|
__ieee754_hypot( double, double );
|
__ieee754_hypot( double, double );
|
|
|
externC double
|
externC double
|
__ieee754_j0( double );
|
__ieee754_j0( double );
|
|
|
externC double
|
externC double
|
__ieee754_j1( double );
|
__ieee754_j1( double );
|
|
|
externC double
|
externC double
|
__ieee754_y0( double );
|
__ieee754_y0( double );
|
|
|
externC double
|
externC double
|
__ieee754_y1( double );
|
__ieee754_y1( double );
|
|
|
externC double
|
externC double
|
__ieee754_jn( int, double );
|
__ieee754_jn( int, double );
|
|
|
externC double
|
externC double
|
__ieee754_yn( int, double );
|
__ieee754_yn( int, double );
|
|
|
externC double
|
externC double
|
__ieee754_remainder( double, double );
|
__ieee754_remainder( double, double );
|
|
|
externC int
|
externC int
|
__ieee754_rem_pio2( double, double * );
|
__ieee754_rem_pio2( double, double * );
|
|
|
#ifdef CYGFUN_LIBM_SVID3_scalb
|
#ifdef CYGFUN_LIBM_SVID3_scalb
|
externC double
|
externC double
|
__ieee754_scalb( double, double );
|
__ieee754_scalb( double, double );
|
#else
|
#else
|
externC double
|
externC double
|
__ieee754_scalb( double, int );
|
__ieee754_scalb( double, int );
|
#endif
|
#endif
|
|
|
// FDLIBM kernel functions
|
// FDLIBM kernel functions
|
|
|
externC double
|
externC double
|
__kernel_standard( double, double, int );
|
__kernel_standard( double, double, int );
|
|
|
externC double
|
externC double
|
__kernel_sin( double, double, int );
|
__kernel_sin( double, double, int );
|
|
|
externC double
|
externC double
|
__kernel_cos( double, double );
|
__kernel_cos( double, double );
|
|
|
externC double
|
externC double
|
__kernel_tan( double, double, int );
|
__kernel_tan( double, double, int );
|
|
|
externC int
|
externC int
|
__kernel_rem_pio2( double *, double *, int, int, int, const int * );
|
__kernel_rem_pio2( double *, double *, int, int, int, const int * );
|
|
|
#endif // ifdef CYGPKG_LIBM
|
#endif // ifdef CYGPKG_LIBM
|
|
|
#endif // CYGONCE_LIBM_MATHINCL_FDLIBM_H multiple inclusion protection
|
#endif // CYGONCE_LIBM_MATHINCL_FDLIBM_H multiple inclusion protection
|
|
|
// EOF fdlibm.h
|
// EOF fdlibm.h
|
|
|