math.h revision 78cbab32dbc1ff1bb306f46e347c68adaf19b35e
/** @file
* IPRT / No-CRT - math.h.
*/
/*
* Copyright (C) 2006-2007 Sun Microsystems, Inc.
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* The contents of this file may alternatively be used under the terms
* of the Common Development and Distribution License Version 1.0
* (CDDL) only, as it comes in the "COPYING.CDDL" file of the
* VirtualBox OSE distribution, in which case the provisions of the
* CDDL are applicable instead of those of the GPL.
*
* You may elect to license modified versions of this file under the
* terms and conditions of either the GPL or the CDDL or both.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 USA or visit http://www.sun.com if you need
* additional information or have any questions.
* --------------------------------------------------------------------
*
* This code is based on:
*
* from: @(#)fdlibm.h 5.1 93/09/24
* FreeBSD HEAD 2005-06-xx
*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
* Developed at SunPro, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
* software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
#ifndef ___iprt_nocrt_math_h
#define ___iprt_nocrt_math_h
#if !defined(__GNUC__) /* && !defined(__YOUR_COMPILER__) */
# error "IPRT: Adjust this header for your compiler"
#endif
/*#include <machine/_limits.h>*/
#if defined(__GNUC__) && !defined(__INTEL_COMPILER)
#else
#endif
#define __pure2
/*
*/
extern const union __infinity_un {
unsigned char __uc[8];
double __ud;
} RT_NOCRT(__infinity);
extern const union __nan_un {
unsigned char __uc[sizeof(float)];
float __uf;
#define __MATH_BUILTIN_CONSTANTS
#endif
#define __MATH_BUILTIN_RELOPS
#endif
#ifdef __MATH_BUILTIN_CONSTANTS
#define HUGE_VAL __builtin_huge_val()
#else
#endif
#if 1/* __ISO_C_VISIBLE >= 1999*/
#define FP_ILOGBNAN __INT_MAX
#ifdef __MATH_BUILTIN_CONSTANTS
#define HUGE_VALF __builtin_huge_valf()
#define HUGE_VALL __builtin_huge_vall()
#define INFINITY __builtin_inf()
#else
#endif /* __MATH_BUILTIN_CONSTANTS */
#define MATH_ERRNO 1
#define MATH_ERREXCEPT 2
#define math_errhandling MATH_ERREXCEPT
#if defined(__ia64__) || defined(__sparc64__)
#define FP_FAST_FMA
#endif
#ifdef __ia64__
#define FP_FAST_FMAL
#endif
#define FP_FAST_FMAF
/* Symbolic constants to classify floating point numbers. */
#define FP_INFINITE 0x01
#define FP_NAN 0x02
#define FP_NORMAL 0x04
#define FP_SUBNORMAL 0x08
#define FP_ZERO 0x10
#define fpclassify(x) \
((sizeof (x) == sizeof (float)) ? RT_NOCRT(__fpclassifyf)(x) \
: (sizeof (x) == sizeof (double)) ? RT_NOCRT(__fpclassifyd)(x) \
: RT_NOCRT(__fpclassifyl)(x))
#define isfinite(x) \
((sizeof (x) == sizeof (float)) ? RT_NOCRT(__isfinitef)(x) \
: (sizeof (x) == sizeof (double)) ? RT_NOCRT(__isfinite)(x) \
: RT_NOCRT(__isfinitel)(x))
#define isinf(x) \
: (sizeof (x) == sizeof (double)) ? isinf(x) \
#define isnan(x) \
((sizeof (x) == sizeof (float)) ? isnanf(x) \
: (sizeof (x) == sizeof (double)) ? isnan(x) \
#define isnormal(x) \
((sizeof (x) == sizeof (float)) ? RT_NOCRT(__isnormalf)(x) \
: (sizeof (x) == sizeof (double)) ? RT_NOCRT(__isnormal)(x) \
: RT_NOCRT(__isnormall)(x))
#ifdef __MATH_BUILTIN_RELOPS
#define isgreater(x, y) __builtin_isgreater((x), (y))
#define isgreaterequal(x, y) __builtin_isgreaterequal((x), (y))
#define isless(x, y) __builtin_isless((x), (y))
#define islessequal(x, y) __builtin_islessequal((x), (y))
#define islessgreater(x, y) __builtin_islessgreater((x), (y))
#define isunordered(x, y) __builtin_isunordered((x), (y))
#else
#define isgreater(x, y) (!isunordered((x), (y)) && (x) > (y))
#define isgreaterequal(x, y) (!isunordered((x), (y)) && (x) >= (y))
#define isless(x, y) (!isunordered((x), (y)) && (x) < (y))
#define islessequal(x, y) (!isunordered((x), (y)) && (x) <= (y))
#define islessgreater(x, y) (!isunordered((x), (y)) && \
((x) > (y) || (y) > (x)))
#endif /* __MATH_BUILTIN_RELOPS */
#define signbit(x) \
((sizeof (x) == sizeof (float)) ? RT_NOCRT(__signbitf)(x) \
: RT_NOCRT(__signbitl)(x))
typedef double double_t;
typedef float float_t;
#endif /* __ISO_C_VISIBLE >= 1999 */
/*
*/
#if 1/* __BSD_VISIBLE || __XSI_VISIBLE*/
#define MAXFLOAT ((float)3.40282346638528860e+38)
#endif /* __BSD_VISIBLE || __XSI_VISIBLE */
#if 1/* __BSD_VISIBLE*/
#if 0
/* Old value from 4.4BSD-Lite math.h; this is probably better. */
#else
#endif
#endif /* __BSD_VISIBLE */
/*
* Most of these functions depend on the rounding mode and have the side
* effect of raising floating-point exceptions, so they are not declared
* as __pure2. In C99, FENV_ACCESS affects the purity of these functions.
*/
/*
*/
/*
* These functions are not in C90.
*/
#if 1 /*__BSD_VISIBLE || __ISO_C_VISIBLE >= 1999 || __XSI_VISIBLE*/
/*int isinf(double) __pure2;*/
/*int isnan(double) __pure2;*/
#endif /* __BSD_VISIBLE || __ISO_C_VISIBLE >= 1999 || __XSI_VISIBLE */
#if 1/* __BSD_VISIBLE || __XSI_VISIBLE*/
#if 1/* __XSI_VISIBLE <= 500 || __BSD_VISIBLE*/
#endif
#endif /* __BSD_VISIBLE || __XSI_VISIBLE */
#if 1/* __BSD_VISIBLE || __ISO_C_VISIBLE >= 1999*/
#endif
/*
* BSD math library entry points
*/
#if 1/* __BSD_VISIBLE*/
/*
* Reentrant version of gamma & lgamma; passes signgam back by reference
* as the second argument; user must allocate space for signgam.
*/
/*
* IEEE Test Vector
*/
double RT_NOCRT(significand)(double);
#endif /* __BSD_VISIBLE */
#if 1/* __ISO_C_VISIBLE >= 1999*/
float RT_NOCRT(nearbyintf)(float);
float RT_NOCRT(nextafterf)(float, float);
float RT_NOCRT(remainderf)(float, float);
#endif
/*
* float versions of BSD math library entry points
*/
#if 1/* __BSD_VISIBLE*/
/*
* Float versions of reentrant version of gamma & lgamma; passes
* signgam back by reference as the second argument; user must
* allocate space for signgam.
*/
/*
* float version of IEEE Test Vector
*/
float RT_NOCRT(significandf)(float);
#endif /* __BSD_VISIBLE */
/*
*/
#if 1/* __ISO_C_VISIBLE >= 1999*/
#if 1 /* bird: we've got these */
#endif
#if 1 /* bird */
#endif
#if 1 /* bird */
#endif
#if 1 /* bird */
#endif
#if 1 /* bird */
#endif
#if 1 /* bird */
#endif
#if 1 /* bird */
long double RT_NOCRT(nearbyintl)(long double);
#endif
long double RT_NOCRT(nextafterl)(long double, long double);
double RT_NOCRT(nexttoward)(double, long double);
float RT_NOCRT(nexttowardf)(float, long double);
long double RT_NOCRT(nexttowardl)(long double, long double);
#if 1 /* bird */
long double RT_NOCRT(remainderl)(long double, long double);
#endif
#if 1 /* bird: we 've got most of these. */
#endif
/* bird: these were missing, gcc apparently inlines them. */
#endif /* __ISO_C_VISIBLE >= 1999 */
#if 1/*def __USE_GNU*/
/*
* block some pages ago. We need this to get the math tests going.
*/
#define M_El 2.7182818284590452353602874713526625L
#define M_LOG2El 1.4426950408889634073599246810018921L
#define M_LOG10El 0.4342944819032518276511289189166051L
#define M_LN2l 0.6931471805599453094172321214581766L
#define M_LN10l 2.3025850929940456840179914546843642L
#define M_PIl 3.1415926535897932384626433832795029L
#define M_PI_2l 1.5707963267948966192313216916397514L
#define M_PI_4l 0.7853981633974483096156608458198757L
#define M_1_PIl 0.3183098861837906715377675267450287L
#define M_2_PIl 0.6366197723675813430755350534900574L
#define M_2_SQRTPIl 1.1283791670955125738961589031215452L
#define M_SQRT2l 1.4142135623730950488016887242096981L
#define M_SQRT1_2l 0.7071067811865475244008443621048490L
#endif
#if 1/*def __USE_GNU*/
long double RT_NOCRT(significandl)(long double);
#endif
#if !defined(RT_WITHOUT_NOCRT_WRAPPERS) && !defined(RT_WITHOUT_NOCRT_WRAPPER_ALIASES)
/* sed -e "/#/d" -e "/RT_NOCRT/!d" -e "s/^.*RT_NOCRT(\([a-z0-9_]*\)).*$/# define \1 RT_NOCRT(\1)/" */
#endif
/*
* Include inlined implementations.
*/
#ifdef RT_ARCH_AMD64
#elif defined(RT_ARCH_X86)
#endif
#endif