Commit 5698852e authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto

Merge pull request #1311 from cremno/msvc-2013-support

Visual Studio 2013 support (and two other fixes)
parents 9f154dd7 bc91bcef
...@@ -51,23 +51,29 @@ ...@@ -51,23 +51,29 @@
typedef short mrb_sym; typedef short mrb_sym;
#ifdef _MSC_VER #ifdef _MSC_VER
# define _ALLOW_KEYWORD_MACROS # ifndef __cplusplus
# include <float.h> # define inline __inline
# define inline __inline # endif
# define snprintf _snprintf # define snprintf _snprintf
# define isnan _isnan # if _MSC_VER < 1800
# define isinf(n) (!_finite(n) && !_isnan(n)) # include <float.h>
# define strtoll _strtoi64 # define isnan _isnan
# define PRId32 "I32d" # define isinf(n) (!_finite(n) && !_isnan(n))
# define PRIi32 "I32i" # define strtoll _strtoi64
# define PRIo32 "I32o" # define strtof (float)strtod
# define PRIx32 "I32x" # define PRId32 "I32d"
# define PRIX32 "I32X" # define PRIi32 "I32i"
# define PRId64 "I64d" # define PRIo32 "I32o"
# define PRIi64 "I64i" # define PRIx32 "I32x"
# define PRIo64 "I64o" # define PRIX32 "I32X"
# define PRIx64 "I64x" # define PRId64 "I64d"
# define PRIX64 "I64X" # define PRIi64 "I64i"
# define PRIo64 "I64o"
# define PRIx64 "I64x"
# define PRIX64 "I64X"
# else
# include <inttypes.h>
# endif
#else #else
# include <inttypes.h> # include <inttypes.h>
#endif #endif
......
...@@ -12,8 +12,8 @@ ...@@ -12,8 +12,8 @@
#define domain_error(msg) \ #define domain_error(msg) \
mrb_raise(mrb, E_RANGE_ERROR, "Numerical argument is out of domain - " #msg) mrb_raise(mrb, E_RANGE_ERROR, "Numerical argument is out of domain - " #msg)
/* math functions not provided under Microsoft Visual C++ */ /* math functions not provided by Microsoft Visual C++ 2012 or older */
#ifdef _MSC_VER #if defined _MSC_VER && _MSC_VER < 1800
#define MATH_TOLERANCE 1E-12 #define MATH_TOLERANCE 1E-12
...@@ -87,6 +87,12 @@ erfc(double x) ...@@ -87,6 +87,12 @@ erfc(double x)
return one_sqrtpi*exp(-x*x)*q2; return one_sqrtpi*exp(-x*x)*q2;
} }
double
log2(double x)
{
return log10(x)/log10(2.0);
}
#endif #endif
/* /*
...@@ -358,18 +364,6 @@ math_atanh(mrb_state *mrb, mrb_value obj) ...@@ -358,18 +364,6 @@ math_atanh(mrb_state *mrb, mrb_value obj)
# define log10(x) ((x) < 0.0 ? nan("") : log10(x)) # define log10(x) ((x) < 0.0 ? nan("") : log10(x))
#endif #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: * call-seq:
* Math.exp(x) -> float * Math.exp(x) -> float
......
...@@ -15,10 +15,6 @@ ...@@ -15,10 +15,6 @@
#include <math.h> #include <math.h>
#include <ctype.h> #include <ctype.h>
#ifdef _MSC_VER
#include <float.h>
#endif
#ifdef HAVE_IEEEFP_H #ifdef HAVE_IEEEFP_H
#include <ieeefp.h> #include <ieeefp.h>
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment