1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2025-10-04 13:27:14 +00:00

Build fixes for clang; little CMake config update

This commit is contained in:
fgenesis 2012-02-10 20:28:35 +01:00
commit 9b2c18ecaa
4 changed files with 50 additions and 47 deletions

View file

@ -17,6 +17,34 @@
// ****
namespace ByteBufferTools
{
template<size_t T> inline void convert(char *val)
{
std::swap(*val, *(val + T - 1));
convert<T - 2>(val + 1);
}
template<> inline void convert<0>(char *) {}
template<> inline void convert<1>(char *) {}
template<typename T> inline void EndianConvert(T *val)
{
convert<sizeof(T)>((char *)(val));
}
#if BB_IS_BIG_ENDIAN
template<typename T> inline void ToLittleEndian(T& val) { EndianConvert<T>(&val); }
template<typename T> inline void ToBigEndian(T&) { }
#else
template<typename T> inline void ToLittleEndian(T&) { }
template<typename T> inline void ToBigEndian(T& val) { EndianConvert<T>(&val); }
#endif
template<typename T> void ToLittleEndian(T*); // will generate link error
template<typename T> void ToBigEndian(T*); // will generate link error
};
#define BB_MAKE_WRITE_OP(T) inline ByteBuffer& operator<<(T val) { append<T>(val); return *this; }
#define BB_MAKE_READ_OP(T) inline ByteBuffer& operator>>(T &val) { val = read<T>(); return *this; }
@ -285,7 +313,7 @@ public:
if(pos + sizeof(T) > size())
BYTEBUFFER_EXCEPT(this, "read", sizeof(T));
T val = *((T const*)(_buf + pos));
ToLittleEndian<T>(val);
ByteBufferTools::ToLittleEndian<T>(val);
return val;
}
@ -321,7 +349,7 @@ public:
template <typename T> void append(T value)
{
ToLittleEndian<T>(value);
ByteBufferTools::ToLittleEndian<T>(value);
_enlargeIfReq(_wpos + sizeof(T));
*((T*)(_buf + _wpos)) = value;
_wpos += sizeof(T);
@ -354,7 +382,7 @@ public:
if(pos >= size())
BYTEBUFFER_EXCEPT(this, "put", sizeof(T));
ToLittleEndian<T>(value);
ByteBufferTools::ToLittleEndian<T>(value);
*((T*)(_buf + pos)) = value;
}
@ -435,34 +463,6 @@ protected:
}
}
template<size_t T> inline static void convert(char *val)
{
std::swap(*val, *(val + T - 1));
convert<T - 2>(val + 1);
}
template<> inline static void convert<0>(char *) {}
template<> inline static void convert<1>(char *) {}
template<typename T> inline static void EndianConvert(T *val)
{
convert<sizeof(T)>((char *)(val));
}
#if BB_IS_BIG_ENDIAN
template<typename T> inline static void ToLittleEndian(T& val) { EndianConvert<T>(&val); }
template<typename T> inline static void ToBigEndian(T&) { }
#else
template<typename T> inline static void ToLittleEndian(T&) { }
template<typename T> inline static void ToBigEndian(T& val) { EndianConvert<T>(&val); }
#endif
template<typename T> static void ToLittleEndian(T*); // will generate link error
template<typename T> static void ToBigEndian(T*); // will generate link error
inline static void ToLittleEndian(uint8&) { }
inline static void ToLittleEndian(int8&) { }
inline static void ToBigEndian(uint8&) { }
inline static void ToBigEndian( int8&) { }
};

View file

@ -169,7 +169,7 @@ void DeflateCompressor::Decompress(void)
if(origsize != rs)
{
char errbuf[256];
sprintf(errbuf, "DeflateCompressor: Inflate error! result=%d cursize=%u origsize=%u realsize=%u",size(),origsize,rs);
sprintf(errbuf, "DeflateCompressor: Inflate error! cursize=%u origsize=%u realsize=%u",size(),origsize,rs);
errorLog(errbuf);
delete [] target;
return;

View file

@ -155,7 +155,7 @@ void *ThreadPool::u_createThread()
th = SDL_CreateThread(threadpool_runner, this);
#endif
if (!th)
return false;
return NULL;
u_addThread(th);
return th;
}