]> de.git.xonotic.org Git - xonotic/netradiant.git/commitdiff
portability improvements
authorspog <spog>
Mon, 29 May 2006 12:19:59 +0000 (12:19 +0000)
committerspog <spog>
Mon, 29 May 2006 12:19:59 +0000 (12:19 +0000)
git-svn-id: svn://svn.icculus.org/gtkradiant/GtkRadiant/trunk@71 8a3a26a2-13c4-0310-b231-cf6edde360e5

libs/bytestreamutils.h
libs/math/vector.h
radiant/commands.cpp
radiant/qgl.cpp

index 1e39b964ca12790bc742b1ad86c4347add744e2c..c340d5443d0303595853f5bf12956a37085a9ff6 100644 (file)
@@ -22,16 +22,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #if !defined(INCLUDED_BYTESTREAMUTILS_H)
 #define INCLUDED_BYTESTREAMUTILS_H
 
-#include <algorithm>
-
-#if defined(_MSC_VER)
-
-typedef signed short int16_t;
-typedef unsigned short uint16_t;
-typedef signed int int32_t;
-typedef unsigned int uint32_t;
-
-#else
+#if defined(__GCC__)
 
 #define        _ISOC9X_SOURCE  1
 #define _ISOC99_SOURCE 1
@@ -43,6 +34,24 @@ typedef unsigned int uint32_t;
 
 #endif
 
+#include <algorithm>
+
+// if C99 is unavailable, fall back to the types most likely to be the right sizes
+#if !defined(int16_t)
+typedef signed short int16_t;
+#endif
+#if !defined(uint16_t)
+typedef unsigned short uint16_t;
+#endif
+#if !defined(int32_t)
+typedef signed int int32_t;
+#endif
+#if !defined(uint32_t)
+typedef unsigned int uint32_t;
+#endif
+
+
+
 
 template<typename InputStreamType, typename Type>
 inline void istream_read_little_endian(InputStreamType& istream, Type& value)
index 15c31def3aaf871ef252c3a910c591c9b7d223df..777d9d3815526a730817ac88ea9f641125965650 100644 (file)
@@ -27,13 +27,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
 #include "generic/vector.h"
 
-#if 0
-
-#define        lrint(dbl)              ((int)((dbl) + 0.5))
-#define        lrintf(flt)             ((int)((flt) + 0.5))
-
-#endif
-
 #if defined (_MSC_VER)
 
 inline int lrint (double flt)
@@ -49,20 +42,31 @@ inline int lrint (double flt)
        return i;
 } 
 
-#else // lrint is part of ISO C99
+#elif defined(__FreeBSD__)
 
+inline int lrint(double f)
+{
+  return static_cast<int>(f + 0.5);
+}
+
+#elif defined(__GCC__)
+
+ // lrint is part of ISO C99
 #define        _ISOC9X_SOURCE  1
 #define _ISOC99_SOURCE 1
 
 #define        __USE_ISOC9X    1
 #define        __USE_ISOC99    1
 
+#else
+#error "unsupported platform"
 #endif
 
 #include <cmath>
 #include <float.h>
 #include <algorithm>
 
+
 //#include "debugging/debugging.h"
 
 /// \brief Returns true if \p self is equal to other \p other within \p epsilon.
index 2c1b49e79ee36c909e9a4a51bd467d61c7813b1b..c1e1b2a3851746333a8fd567f5fd4d9f2f5a2971 100644 (file)
@@ -126,18 +126,7 @@ const KeyEvent& GlobalKeyEvents_find(const char* name)
 
 
 
-#include <ctype.h>
-
-#ifdef __APPLE__
-#define __toascii(c)    ((c) & 0x7f)
-#endif
-
-inline char ascii_for_keyval(int keyval)
-{
-  return __toascii(keyval);
-}
-
-
+#include <cctype>
 
 #include <gtk/gtkbox.h>
 #include <gtk/gtkliststore.h>
@@ -284,7 +273,7 @@ void SaveCommandMap(const char* path)
         }
         else if(accelerator.key != 0)
         {
-          m_file << ascii_for_keyval(accelerator.key);
+          m_file << gdk_keyval_name(accelerator.key);
         }
 
         if(accelerator.modifiers & GDK_MOD1_MASK)
index c1e6b23acd3fab8d7a22188c191ffb3dbbc6b2c9..5a6477d1d2b46a37b94a55b23e3ee30fae27fd19 100644 (file)
@@ -657,7 +657,7 @@ int QGL_Init(OpenGLBinding& table)
   qglXUseXFont                 = glXUseXFont;
 //  qglXGetProcAddressARB        = glXGetProcAddressARB; // Utah-GLX fix
 
-  qglXGetProcAddressARB = (glXGetProcAddressARBProc)dlsym(NULL, "glXGetProcAddressARB"); 
+  qglXGetProcAddressARB = (glXGetProcAddressARBProc)dlsym(RTLD_DEFAULT, "glXGetProcAddressARB"); 
   if ((qglXQueryExtension == 0) || (qglXQueryExtension(GDK_DISPLAY(),0,0) != True))
     return 0;
 #else