Skip to content

Commit

Permalink
Fix compilation with MSVC2015
Browse files Browse the repository at this point in the history
  • Loading branch information
vitallium committed May 19, 2016
1 parent 38e51b2 commit 9e94ff2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
5 changes: 4 additions & 1 deletion Source/WTF/wtf/Compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef WTF_Compiler_h
Expand Down Expand Up @@ -70,10 +70,13 @@

/* COMPILER(MSVC) - Microsoft Visual C++ */
/* COMPILER(MSVC9_OR_LOWER) - Microsoft Visual C++ 2008 or lower*/
/* COMPILER(MSVC12_OR_LOWER) - Microsoft Visual C++ 2013 or lower */
#if defined(_MSC_VER)
#define WTF_COMPILER_MSVC 1
#if _MSC_VER < 1600
#define WTF_COMPILER_MSVC9_OR_LOWER 1
#elif _MSC_VER < 1800
#define WTF_COMPILER_MSVC12_OR_LOWER 1
#endif

/* Specific compiler features */
Expand Down
9 changes: 6 additions & 3 deletions Source/WTF/wtf/MathExtras.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef WTF_MathExtras_h
Expand Down Expand Up @@ -139,7 +139,7 @@ static float roundf(float num)
return integer - num > 0.5f ? integer - 1.0f : integer;
return integer - num >= 0.5f ? integer - 1.0f : integer;
}
#endif

inline long long llround(double num) { return static_cast<long long>(round(num)); }
inline long long llroundf(float num) { return static_cast<long long>(roundf(num)); }
inline long lround(double num) { return static_cast<long>(round(num)); }
Expand All @@ -153,7 +153,7 @@ inline double trunc(double num) { return num > 0 ? floor(num) : ceil(num); }
inline long long abs(long num) { return labs(num); }
#endif

#if OS(ANDROID) || COMPILER(MSVC)
#if OS(ANDROID) || COMPILER(MSVC12_OR_LOWER)
// ANDROID and MSVC's math.h does not currently supply log2 or log2f.
inline double log2(double num)
{
Expand All @@ -174,6 +174,7 @@ inline float log2f(float num)
inline long long abs(long long num) { return _abs64(num); }
#endif

#if COMPILER(MSVC12_OR_LOWER)
namespace std {

inline bool isinf(double num) { return !_finite(num) && !_isnan(num); }
Expand Down Expand Up @@ -245,6 +246,8 @@ inline long int lrint(double flt)
return static_cast<long int>(intgr);
}

#endif // COMPILER(MSVC12_OR_LOWER)

#endif // COMPILER(MSVC)

inline double deg2rad(double d) { return d * piDouble / 180.0; }
Expand Down

0 comments on commit 9e94ff2

Please sign in to comment.