Visual Studio 2013 support + strtof + inline

- VC12 has better C99 library support due to C++11
- defined strtof for VC11 or older
- define "inline" only if the C compiler is used
This commit is contained in:
Cremno
2013-06-27 12:18:35 +02:00
parent b44309b4b2
commit 8728837478
3 changed files with 30 additions and 36 deletions
+22 -18
View File
@@ -51,25 +51,29 @@
typedef short mrb_sym;
#ifdef _MSC_VER
# define _ALLOW_KEYWORD_MACROS
# include <float.h>
# define inline __inline
# ifndef __cplusplus
# define inline __inline
# endif
# define snprintf _snprintf
# define isnan _isnan
# define isinf(n) (!_finite(n) && !_isnan(n))
# define strtoll _strtoi64
# define PRId32 "I32d"
# define PRIi32 "I32i"
# define PRIo32 "I32o"
# define PRIx32 "I32x"
# define PRIX32 "I32X"
# define PRId64 "I64d"
# define PRIi64 "I64i"
# define PRIo64 "I64o"
# define PRIx64 "I64x"
# define PRIX64 "I64X"
#else
# include <inttypes.h>
# if _MSC_VER < 1800
# include <float.h>
# define isnan _isnan
# define isinf(n) (!_finite(n) && !_isnan(n))
# define strtoll _strtoi64
# define strtof (float)strtod
# define PRId32 "I32d"
# define PRIi32 "I32i"
# define PRIo32 "I32o"
# define PRIx32 "I32x"
# define PRIX32 "I32X"
# define PRId64 "I64d"
# define PRIi64 "I64i"
# define PRIo64 "I64o"
# define PRIx64 "I64x"
# define PRIX64 "I64X"
# else
# include <inttypes.h>
# endif
#endif
typedef uint8_t mrb_bool;
+8 -14
View File
@@ -12,8 +12,8 @@
#define domain_error(msg) \
mrb_raise(mrb, E_RANGE_ERROR, "Numerical argument is out of domain - " #msg)
/* math functions not provided under Microsoft Visual C++ */
#ifdef _MSC_VER
/* math functions not provided by Microsoft Visual C++ 2012 or older */
#if defined _MSC_VER && _MSC_VER < 1800
#define MATH_TOLERANCE 1E-12
@@ -87,6 +87,12 @@ erfc(double x)
return one_sqrtpi*exp(-x*x)*q2;
}
double
log2(double x)
{
return log10(x)/log10(2.0);
}
#endif
/*
@@ -358,18 +364,6 @@ math_atanh(mrb_state *mrb, mrb_value obj)
# define log10(x) ((x) < 0.0 ? nan("") : log10(x))
#endif
#ifndef log2
#ifndef HAVE_LOG2
double
log2(double x)
{
return log10(x)/log10(2.0);
}
#else
extern double log2(double);
#endif
#endif
/*
* call-seq:
* Math.exp(x) -> float
-4
View File
@@ -15,10 +15,6 @@
#include <math.h>
#include <ctype.h>
#ifdef _MSC_VER
#include <float.h>
#endif
#ifdef HAVE_IEEEFP_H
#include <ieeefp.h>
#endif