From: spog Date: Mon, 29 May 2006 12:19:59 +0000 (+0000) Subject: portability improvements X-Git-Tag: xonotic-v0.7.0~16^2~12^2~223 X-Git-Url: https://git.xonotic.org/?a=commitdiff_plain;h=501f88301a06994affeac524b24541c3d7a651c0;p=xonotic%2Fnetradiant.git portability improvements git-svn-id: svn://svn.icculus.org/gtkradiant/GtkRadiant/trunk@71 8a3a26a2-13c4-0310-b231-cf6edde360e5 --- diff --git a/libs/bytestreamutils.h b/libs/bytestreamutils.h index 1e39b964..c340d544 100644 --- a/libs/bytestreamutils.h +++ b/libs/bytestreamutils.h @@ -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 - -#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 + +// 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 inline void istream_read_little_endian(InputStreamType& istream, Type& value) diff --git a/libs/math/vector.h b/libs/math/vector.h index 15c31def..777d9d38 100644 --- a/libs/math/vector.h +++ b/libs/math/vector.h @@ -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(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 #include #include + //#include "debugging/debugging.h" /// \brief Returns true if \p self is equal to other \p other within \p epsilon. diff --git a/radiant/commands.cpp b/radiant/commands.cpp index 2c1b49e7..c1e1b2a3 100644 --- a/radiant/commands.cpp +++ b/radiant/commands.cpp @@ -126,18 +126,7 @@ const KeyEvent& GlobalKeyEvents_find(const char* name) -#include - -#ifdef __APPLE__ -#define __toascii(c) ((c) & 0x7f) -#endif - -inline char ascii_for_keyval(int keyval) -{ - return __toascii(keyval); -} - - +#include #include #include @@ -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) diff --git a/radiant/qgl.cpp b/radiant/qgl.cpp index c1e6b23a..5a6477d1 100644 --- a/radiant/qgl.cpp +++ b/radiant/qgl.cpp @@ -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