changeset 188:56c167f3648a

compilation under linux: resolve bug with std::min
author lbajardsilogic
date Tue, 27 Nov 2007 13:11:19 +0000
parents be6f263fa0ab
children 6a31322cd9ed
files system/System.h
diffstat 1 files changed, 85 insertions(+), 80 deletions(-) [+]
line wrap: on
line diff
--- a/system/System.h	Mon Nov 26 17:08:38 2007 +0000
+++ b/system/System.h	Tue Nov 27 13:11:19 2007 +0000
@@ -16,6 +16,8 @@
 #ifndef _SYSTEM_H_
 #define _SYSTEM_H_
 
+//#include <cmath>
+
 #ifdef _WIN32
 
 #include <windows.h>
@@ -30,80 +32,80 @@
 
 typedef int WINBOOL;
 
-typedef signed char int8_t;
-typedef unsigned char   uint8_t;
-typedef short  int16_t;
-typedef unsigned short  uint16_t;
+typedef signed char int8_t;
+typedef unsigned char   uint8_t;
+typedef short  int16_t;
+typedef unsigned short  uint16_t;
 typedef long ssize_t;
 typedef unsigned short mode_t;
 
-#define	_S_IWUSR	_S_IWRITE
-#define	_S_IRUSR	_S_IREAD
-#define	S_IRUSR		_S_IRUSR
+#define	_S_IWUSR	_S_IWRITE
+#define	_S_IRUSR	_S_IREAD
+#define	S_IRUSR		_S_IRUSR
 #define	S_IWUSR		_S_IWUSR
 
-/* If we're not using GNU C, elide __attribute__ */
-#ifndef __GNUC__
-#  define  __attribute__(x)  /*NOTHING*/
+/* If we're not using GNU C, elide __attribute__ */
+#ifndef __GNUC__
+#  define  __attribute__(x)  /*NOTHING*/
 #endif
 
-/*  Win32 doesn't seem to have these functions. 
-**	Therefore implement inline versions of these functions here.
-*/
-	
-__inline long int lrint (double flt)
-{	int intgr;
-	_asm
-	{	fld flt
-		fistp intgr
-	} ;
-			
-	return intgr ;
-} 
-	
-__inline long int lrintf (float flt)
-{	int intgr;
-	_asm
-	{	fld flt
-		fistp intgr
-	} ;
-		
-	return intgr ;
-}
-
-__inline double nearbyint(double x)
-{
-    unsigned int tmpMSW1;
-    unsigned int tmpMSW2;
-    __asm {
-        // get current state
-        fnstcw tmpMSW1
-    }
-    // set bit 5
-    tmpMSW2 = tmpMSW1 | 0x00000020;
-	__asm {
-        // and load
-        fldcw tmpMSW2
-        // do the job
-        fld x
-        frndint
-        // clear exception
-        fclex
-        // restore old state
-        fldcw tmpMSW1
-    }
+/*  Win32 doesn't seem to have these functions. 
+**	Therefore implement inline versions of these functions here.
+*/
+	
+__inline long int lrint (double flt)
+{	int intgr;
+	_asm
+	{	fld flt
+		fistp intgr
+	} ;
+			
+	return intgr ;
+} 
+	
+__inline long int lrintf (float flt)
+{	int intgr;
+	_asm
+	{	fld flt
+		fistp intgr
+	} ;
+		
+	return intgr ;
 }
 
-#ifndef isinf
-#define isinf(d) ((_fpclass(d) == _FPCLASS_PINF) ? 1 \
-         : ((_fpclass(d) == _FPCLASS_NINF) ? -1 : 0))
-#endif
-/* _isnan(x) returns nonzero if (x == NaN) and zero otherwise. */
-#ifndef isnan
-#define isnan(d) (_isnan(d))
-#endif
-
-#define ftruncate _chsize 
+__inline double nearbyint(double x)
+{
+    unsigned int tmpMSW1;
+    unsigned int tmpMSW2;
+    __asm {
+        // get current state
+        fnstcw tmpMSW1
+    }
+    // set bit 5
+    tmpMSW2 = tmpMSW1 | 0x00000020;
+	__asm {
+        // and load
+        fldcw tmpMSW2
+        // do the job
+        fld x
+        frndint
+        // clear exception
+        fclex
+        // restore old state
+        fldcw tmpMSW1
+    }
+}
+
+#ifndef isinf
+#define isinf(d) ((_fpclass(d) == _FPCLASS_PINF) ? 1 \
+         : ((_fpclass(d) == _FPCLASS_NINF) ? -1 : 0))
+#endif
+/* _isnan(x) returns nonzero if (x == NaN) and zero otherwise. */
+#ifndef isnan
+#define isnan(d) (_isnan(d))
+#endif
+
+#define ftruncate _chsize 
 
 #else /*USE_VC*/
 #include <sys/time.h>
@@ -182,22 +184,25 @@
 
 #endif /* ! _WIN32 */
 
-#ifdef __GNUC__
-
-#ifndef min  
-#define  min(x)  std::min((x)) 
-#endif
-
-#ifndef max
-#define  max(x)  std::max((x)) 
+#include <cmath>
+#include <algorithm>
+
+#ifdef __GNUC__
+
+#ifndef MIN  
+#define  MIN(x, y)  std::min(x, y) 
 #endif
-
-#ifndef isnan  
-#define  isnan(x)  std::isnan((x)) 
+
+#ifndef MAX
+#define  MAX(x, y)  std::max(x, y) 
 #endif
-
-#ifndef isinf  
-#define  isinf(x)  std::isinf((x)) 
+
+#ifndef isnan  
+#define  isnan(x)  std::isnan((x)) 
+#endif
+
+#ifndef isinf  
+#define  isinf(x)  std::isinf((x)) 
 #endif
 
 #endif /* __GNUC__ */
@@ -213,7 +218,7 @@
 // on the partition containing the given path.  Return -1 if unknown.
 extern int GetDiscSpaceMBAvailable(const char *path);
 
-#include <cmath>
+//#include <cmath>
 
 extern double mod(double x, double y);
 extern float modf(float x, float y);