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 4cd12f3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 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
12 changes: 10 additions & 2 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 @@ -140,20 +140,25 @@ static float roundf(float num)
return integer - num >= 0.5f ? integer - 1.0f : integer;
}
#endif

#if COMPILER(MSVC12_OR_LOWER)

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)); }
inline long lroundf(float num) { return static_cast<long>(roundf(num)); }
inline double trunc(double num) { return num > 0 ? floor(num) : ceil(num); }

#endif // COMPILER(MSVC12_OR_LOWER)

#endif

#if COMPILER(GCC) && OS(QNX) && _CPPLIB_VER < 640
// The stdlib on QNX < 6.6 doesn't contain long abs(long). See PR #104666.
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 +179,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 +251,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 4cd12f3

Please sign in to comment.