Fix missing abs() declaration.

Change-Id: I7e4ceea2a45e8767881094de8b69b4d3aadab158
Reviewed-on: https://swiftshader-review.googlesource.com/4354
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>
diff --git a/src/Common/Math.hpp b/src/Common/Math.hpp
index 2f74d05..a23a7d4 100644
--- a/src/Common/Math.hpp
+++ b/src/Common/Math.hpp
@@ -14,17 +14,14 @@
 

 #include "Types.hpp"

 

-#include <math.h>

+#include <cmath>

 #if defined(_MSC_VER)

 	#include <intrin.h>

 #endif

 

 namespace sw

 {

-	inline float abs(float x)

-	{

-		return fabsf(x);

-	}

+	using std::abs;

 

 	#undef min

 	#undef max

diff --git a/src/OpenGL/libGL/Context.cpp b/src/OpenGL/libGL/Context.cpp
index 4d65d64..9365399 100644
--- a/src/OpenGL/libGL/Context.cpp
+++ b/src/OpenGL/libGL/Context.cpp
@@ -37,9 +37,6 @@
 #include <GL/GL.h>

 #include <GL/glext.h>

 

-#undef near

-#undef far

-

 namespace gl

 {

 Context::Context(const Context *shareContext)

diff --git a/src/OpenGL/libGL/libGL.cpp b/src/OpenGL/libGL/libGL.cpp
index 0aa62f4..3d85c14 100644
--- a/src/OpenGL/libGL/libGL.cpp
+++ b/src/OpenGL/libGL/libGL.cpp
@@ -33,6 +33,8 @@
 

 #include <limits>

 

+using std::abs;

+

 static bool validImageSize(GLint level, GLsizei width, GLsizei height)

 {

 	if(level < 0 || level >= gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS || width < 0 || height < 0)

@@ -6560,7 +6562,7 @@
 			if(params[3] == 0.0f)   // Directional light

 			{

 				// Create a very far out point light

-				float max = std::max(std::max(abs(params[0]), abs(params[1])), abs(params[2]));

+				float max = sw::max(abs(params[0]), abs(params[1]), abs(params[2]));

 				device->setLightPosition(light - GL_LIGHT0, sw::Point(params[0] / max * 1e10f, params[1] / max * 1e10f, params[2] / max * 1e10f));

 			}

 			else

diff --git a/src/OpenGL/libGL/mathutil.h b/src/OpenGL/libGL/mathutil.h
index df913af..1055845 100644
--- a/src/OpenGL/libGL/mathutil.h
+++ b/src/OpenGL/libGL/mathutil.h
@@ -15,8 +15,7 @@
 #define LIBGL_MATHUTIL_H_
 
 #include "common/debug.h"
-
-#include <math.h>
+#include "Common/Math.hpp"
 
 namespace gl
 {
diff --git a/src/OpenGL/libGLES_CM/Context.cpp b/src/OpenGL/libGLES_CM/Context.cpp
index d2ea101..aee6f39 100644
--- a/src/OpenGL/libGLES_CM/Context.cpp
+++ b/src/OpenGL/libGLES_CM/Context.cpp
@@ -30,10 +30,7 @@
 

 #include <EGL/eglext.h>

 

-#include <algorithm>

-

-#undef near

-#undef far

+using std::abs;

 

 namespace es1

 {

@@ -1942,7 +1939,7 @@
 		else   // Directional light

 		{

 			// Hack: set the position far way

-			float max = std::max(std::max(abs(light[i].position.x), abs(light[i].position.y)), abs(light[i].position.z));

+			float max = sw::max(abs(light[i].position.x), abs(light[i].position.y), abs(light[i].position.z));

 			device->setLightPosition(i, sw::Point(1e10f * (light[i].position.x / max), 1e10f * (light[i].position.y / max), 1e10f * (light[i].position.z / max)));

 		}

 	}

diff --git a/src/OpenGL/libGLES_CM/mathutil.h b/src/OpenGL/libGLES_CM/mathutil.h
index 8f93020..b88bcca 100644
--- a/src/OpenGL/libGLES_CM/mathutil.h
+++ b/src/OpenGL/libGLES_CM/mathutil.h
@@ -15,8 +15,7 @@
 #define LIBGLES_CM_MATHUTIL_H_
 
 #include "common/debug.h"
-
-#include <math.h>
+#include "Common/Math.hpp"
 
 namespace es1
 {
diff --git a/src/OpenGL/libGLESv2/Context.cpp b/src/OpenGL/libGLESv2/Context.cpp
index 3795da1..af3bae3 100644
--- a/src/OpenGL/libGLESv2/Context.cpp
+++ b/src/OpenGL/libGLESv2/Context.cpp
@@ -37,9 +37,6 @@
 

 #include <EGL/eglext.h>

 

-#undef near

-#undef far

-

 namespace es2

 {

 Context::Context(const egl::Config *config, const Context *shareContext, EGLint clientVersion)

diff --git a/src/OpenGL/libGLESv2/mathutil.h b/src/OpenGL/libGLESv2/mathutil.h
index 8e62a06..3fbbff5 100644
--- a/src/OpenGL/libGLESv2/mathutil.h
+++ b/src/OpenGL/libGLESv2/mathutil.h
@@ -15,8 +15,7 @@
 #define LIBGLESV2_MATHUTIL_H_
 
 #include "common/debug.h"
-
-#include <math.h>
+#include "Common/Math.hpp"
 
 namespace es2
 {
@@ -51,12 +50,12 @@
     return x < min ? min : (x > max ? max : x);
 }
 
-template<class T>

-inline void swap(T &a, T &b)

-{

-	T t = a;

-	a = b;

-	b = t;

+template<class T>
+inline void swap(T &a, T &b)
+{
+	T t = a;
+	a = b;
+	b = t;
 }
 
 inline float clamp01(float x)