portability improvements

git-svn-id: svn://svn.icculus.org/gtkradiant/GtkRadiant/trunk@71 8a3a26a2-13c4-0310-b231-cf6edde360e5
This commit is contained in:
spog 2006-05-29 12:19:59 +00:00
parent 520f83054e
commit 501f88301a
4 changed files with 34 additions and 32 deletions

View 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)

View 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.

View 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)

View 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