view src/build-msvctools/math/math.h.in @ 3061:f8299bb6c872

Initial support for native MSVC compilation. * add MSVC support files: compiler wrappers and support libraries * adapt libiconv to work with MSVC * adapt gettext to work with MSVC
author Michael Goffioul <michael.goffioul@gmail.com>
date Mon, 17 Jun 2013 22:43:11 -0400
parents
children e0257da7fcdc
line wrap: on
line source

/*
 * This file is part of msvcmath library.
 * Author: Michael Goffioul
 */
#ifndef __MSVCMATHLIB_H__
#define __MSVCMATHLIB_H__

#ifndef _MSC_VER
# error "this header can only be used with Visual C++ compiler"
#endif

/* Make sure math constants are defined */
#ifndef _USE_MATH_DEFINES
# define _USE_MATH_DEFINES
#endif

/*
 * Original math.h rom VC++ defines float and long double variants
 * of math functions as inline in C++. This conflicts with C version
 * defined below.
 */
#ifdef __cplusplus
# define frexpf __msvc_frexpf
# ifndef _M_IA64
#  define fabsf __msvc_fabsf
#  define ldexpf __msvc_ldexpf
#  ifndef _M_AMD64
#   define acosf __msvc_acosf
#   define asinf __msvc_asinf
#   define atanf __msvc_atanf
#   define atan2f __msvc_atan2f
#   define ceilf __msvc_ceilf
#   define cosf __msvc_cosf
#   define coshf __msvc_coshf
#   define expf __msvc_expf
#   define floorf __msvc_floorf
#   define fmodf __msvc_fmodf
#   define logf __msvc_logf
#   define log10f __msvc_log10f
#   define modff __msvc_modff
#   define powf __msvc_powf
#   define sinf __msvc_sinf
#   define sinhf __msvc_sinhf
#   define sqrtf __msvc_sqrtf
#   define tanf __msvc_tanf
#   define tanhf __msvc_tanhf
#  endif
# endif
# define acosl __msvc_acosl
# define asinl __msvc_asinl
# define atanl __msvc_atanl
# define atan2l __msvc_atan2l
# define ceill __msvc_ceill
# define cosl __msvc_cosl
# define coshl __msvc_coshl
# define expl __msvc_expl
# define fabsl __msvc_fabsl
# define floorl __msvc_floorl
# define fmodl __msvc_fmodl
# define frexpl __msvc_frexpl
# define ldexpl __msvc_ldexpl
# define logl __msvc_logl
# define log10l __msvc_log10l
# define modfl __msvc_modfl
# define powl __msvc_powl
# define sinl __msvc_sinl
# define sinhl __msvc_sinhl
# define sqrtl __msvc_sqrtl
# define tanl __msvc_tanl
# define tanhl __msvc_tanhl
#endif

/* Include VC++ original math.h */
#include <@MSVCMATH@>

/* Undo override of inlined version in C++ */
#ifdef __cplusplus
# undef frexpf
# ifndef _M_IA64
#  undef fabsf
#  undef ldexpf
#  ifndef _M_AMD64
#   undef acosf
#   undef asinf
#   undef atanf
#   undef atan2f
#   undef ceilf
#   undef cosf
#   undef coshf
#   undef expf
#   undef floorf
#   undef fmodf
#   undef logf
#   undef log10f
#   undef modff
#   undef powf
#   undef sinf
#   undef sinhf
#   undef sqrtf
#   undef tanf
#   undef tanhf
#  endif
# endif
# undef acosl
# undef asinl
# undef atanl
# undef atan2l
# undef ceill
# undef cosl
# undef coshl
# undef expl
# undef fabsl
# undef floorl
# undef fmodl
# undef frexpl
# undef ldexpl
# undef logl
# undef log10l
# undef modfl
# undef powl
# undef sinl
# undef sinhl
# undef sqrtl
# undef tanl
# undef tanhl
#endif

#ifdef __cplusplus
extern "C" {
#endif

/* Override definitions in VC++ math.h */
#undef frexpf
extern float frexpf (float x, int* y);
#ifndef _M_IA64
# undef fabsf
# undef ldexpf
extern float fabsf (float x);
extern float ldexpf (float x, int y);
# ifndef _M_AMD64
#  undef acosf
#  undef asinf
#  undef atanf
#  undef atan2f
#  undef ceilf
#  undef cosf
#  undef coshf
#  undef expf
#  undef floorf
#  undef fmodf
#  undef logf
#  undef log10f
#  undef modff
#  undef powf
#  undef sinf
#  undef sinhf
#  undef sqrtf
#  undef tanf
#  undef tanhf
extern float acosf (float x);
extern float asinf (float x);
extern float atanf (float x);
extern float atan2f (float y, float x);
extern float ceilf (float x);
extern float cosf (float x);
extern float coshf (float x);
extern float expf (float x);
extern float floorf (float x);
extern float fmodf (float x, float y);
extern float logf (float x);
extern float log10f (float x);
extern float modff (float x, float* y);
extern float powf (float x, float y);
extern float sinf (float x);
extern float sinhf (float x);
extern float sqrtf (float x);
extern float tanf (float x);
extern float tanhf (float x);
# endif /* ! _M_AMD64 */
#endif /* ! _M_IA64 */

#undef acosl
#undef asinl
#undef atanl
#undef atan2l
#undef ceill
#undef cosl
#undef coshl
#undef expl
#undef fabsl
#undef floorl
#undef fmodl
#undef frexpl
#undef ldexpl
#undef logl
#undef log10l
#undef modfl
#undef powl
#undef sinl
#undef sinhl
#undef sqrtl
#undef tanl
#undef tanhl
extern long double acosl (long double x);
extern long double asinl (long double x);
extern long double atanl (long double x);
extern long double atan2l (long double y, long double x);
extern long double ceill (long double x);
extern long double cosl (long double x);
extern long double coshl (long double x);
extern long double expl (long double x);
extern long double fabsl (long double x);
extern long double floorl (long double x);
extern long double fmodl (long double x, long double y);
extern long double frexpl (long double x, int* y);
extern long double ldexpl (long double x, int y);
extern long double logl (long double x);
extern long double log10l (long double x);
extern long double modfl (long double x, long double* y);
extern long double powl (long double x, long double y);
extern long double sinl (long double x);
extern long double sinhl (long double x);
extern long double sqrtl (long double x);
extern long double tanl (long double x);
extern long double tanhl (long double x);

/* Inverse hyperbolic functions */
extern double acosh (double x);
extern double asinh (double x);
extern double atanh (double x);
extern float acoshf (float x);
extern float asinhf (float x);
extern float atanhf (float x);
extern long double acoshl (long double x);
extern long double asinhl (long double x);
extern long double atanhl (long double x);

/* Cubic root functions */
extern double cbrt (double x);
extern float cbrtf (float x);
extern long double cbrtl (long double x);

/* Logarithmic functions */
extern double exp2 (double x);
extern double expm1 (double x);
extern int ilogb (double x);
extern double log1p (double x);
extern double log2 (double x);
extern double logb (double x);
extern float exp2f (float x);
extern float expm1f (float x);
extern int ilogbf (float x);
extern float log1pf (float x);
extern float log2f (float x);
extern float logbf (float x);
extern long double exp2l (long double x);
extern long double expm1l (long double x);
extern int ilogbl (long double x);
extern long double log1pl (long double x);
extern long double log2l (long double x);
extern long double logbl (long double x);

/* Rounding functions */
extern long int lrint (double x);
extern long long int llrint (double x);
extern long int lround (double x);
extern double nearbyint (double x);
extern double rint (double x);
extern double round (double x);
extern double trunc (double x);
extern long int lrintf (float x);
extern long long int llrintf (float x);
extern long int lroundf (float x);
extern float nearbyintf (float x);
extern float rintf (float x);
extern float roundf (float x);
extern float truncf (float x);
extern long int lrintl (long double x);
extern long long int llrintl (long double x);
extern long int lroundl (long double x);
extern long double nearbyintl (long double x);
extern long double rintl (long double x);
extern long double roundl (long double x);
extern long double truncl (long double x);

/* Other functions */
extern double fma (double x, double y, double z);
extern float fmaf (float x, float y, float z);
extern long double fmal (long double x, long double y, long double z);

extern int finite(double x);
extern int finitef(float x);
extern int finitel(long double x);

extern int isinf(double x);
extern int isinff(float x);
extern int isinfl(long double x);

extern int isnan(double x);
extern int isnanf(float x);
extern int isnanl(long double x);

extern double nan (const char* tagp);
extern float nanf (const char* tagp);
extern long double nanl (const char* tagp);

extern double nextafter (double x, double y);
extern float nextafterf (float x, float y);
extern long double nextafterl (long double x, long double y);

extern double remainder(double x, double y);
extern float remainderf(float x, float y);
extern long double remainderl(long double x, long double y);

extern double scalbn(double x, int exp);
extern float scalbnf(float x, int exp);
extern long double scalbnl(long double x, int exp);

#ifdef __cplusplus
}
#endif

#endif