mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-19 03:39:08 +00:00
CoreLib fixes for Linux.
This commit is contained in:
@ -7,6 +7,7 @@ if(WIN32 AND NOT CYGWIN)
|
|||||||
endif(WIN32 AND NOT CYGWIN)
|
endif(WIN32 AND NOT CYGWIN)
|
||||||
if(UNIX)
|
if(UNIX)
|
||||||
add_definitions(-DHS_BUILD_FOR_UNIX)
|
add_definitions(-DHS_BUILD_FOR_UNIX)
|
||||||
|
add_definitions(-std=c++0x)
|
||||||
endif(UNIX)
|
endif(UNIX)
|
||||||
# End HeadSpin Configuration
|
# End HeadSpin Configuration
|
||||||
|
|
||||||
|
@ -80,14 +80,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
|||||||
# define NOMINMAX // Needed to prevent NxMath conflicts
|
# define NOMINMAX // Needed to prevent NxMath conflicts
|
||||||
# endif
|
# endif
|
||||||
# include <Windows.h>
|
# include <Windows.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
// Just some fun typedefs...
|
|
||||||
typedef HWND hsWindowHndl;
|
|
||||||
typedef HINSTANCE hsWindowInst;
|
|
||||||
#else
|
|
||||||
typedef int32_t* hsWindowHndl;
|
|
||||||
typedef int32_t* hsWindowInst;
|
|
||||||
#endif // HS_BUILD_FOR_WIN32
|
|
||||||
|
|
||||||
//======================================
|
//======================================
|
||||||
// We don't want the Windows.h min/max!
|
// We don't want the Windows.h min/max!
|
||||||
@ -112,6 +106,18 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
|
||||||
|
//======================================
|
||||||
|
// Just some fun typedefs...
|
||||||
|
//======================================
|
||||||
|
#ifdef HS_BUILD_FOR_WIN32
|
||||||
|
typedef HWND hsWindowHndl;
|
||||||
|
typedef HINSTANCE hsWindowInst;
|
||||||
|
#else
|
||||||
|
typedef int32_t* hsWindowHndl;
|
||||||
|
typedef int32_t* hsWindowInst;
|
||||||
|
#endif // HS_BUILD_FOR_WIN32
|
||||||
|
|
||||||
|
|
||||||
//======================================
|
//======================================
|
||||||
// Basic macros
|
// Basic macros
|
||||||
//======================================
|
//======================================
|
||||||
|
@ -40,7 +40,13 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
|||||||
|
|
||||||
*==LICENSE==*/
|
*==LICENSE==*/
|
||||||
|
|
||||||
#include <intrin.h>
|
#if defined(_MSC_VER) || ((defined(_WIN32) || defined(_WIN64)) && defined(__INTEL_COMPILER))
|
||||||
|
# include <intrin.h>
|
||||||
|
# define MSC_COMPATIBLE
|
||||||
|
#elif defined(__GNUC__)
|
||||||
|
# include <cpuid.h>
|
||||||
|
# define GCC_COMPATIBLE
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "hsCpuID.h"
|
#include "hsCpuID.h"
|
||||||
|
|
||||||
@ -53,15 +59,43 @@ hsCpuId::hsCpuId() {
|
|||||||
const unsigned int sse42_flag = 1<<20;
|
const unsigned int sse42_flag = 1<<20;
|
||||||
const unsigned int avx_flag = 1 << 28;
|
const unsigned int avx_flag = 1 << 28;
|
||||||
|
|
||||||
unsigned int cpu_info[4];
|
unsigned int ax = 0, bx = 0, cx = 0, dx = 0;
|
||||||
__cpuid((int*)cpu_info, 1);
|
|
||||||
has_sse1 = (cpu_info[3] & sse1_flag) || false;
|
|
||||||
has_sse2 = (cpu_info[3] & sse2_flag) || false;
|
/**
|
||||||
has_sse3 = (cpu_info[2] & sse3_flag) || false;
|
* Portable implementation of CPUID, successfully tested with:
|
||||||
has_ssse3 = (cpu_info[2] & ssse3_flag) || false;
|
* - Microsoft Visual Studio 2010,
|
||||||
has_sse41 = (cpu_info[2] & sse41_flag) || false;
|
* - GNU GCC 4.5,
|
||||||
has_sse42 = (cpu_info[2] & sse42_flag) || false;
|
* - Intel C++ Compiler 12.0
|
||||||
has_avx = (cpu_info[2] & avx_flag) || false;
|
* - Sun Studio 12,
|
||||||
|
* - AMD x86 Open64 Compiler Suite.
|
||||||
|
*
|
||||||
|
* Ref: http://primesieve.googlecode.com/svn-history/r388/trunk/soe/cpuid.h
|
||||||
|
*/
|
||||||
|
#if defined(MSC_COMPATIBLE)
|
||||||
|
int CPUInfo[4] = {ax, bx, cx, dx};
|
||||||
|
__cpuid(CPUInfo, 0);
|
||||||
|
|
||||||
|
// check if the CPU supports the cpuid instruction.
|
||||||
|
if (CPUInfo[0] != 0) {
|
||||||
|
__cpuid(CPUInfo, 1);
|
||||||
|
ax = CPUInfo[0];
|
||||||
|
bx = CPUInfo[1];
|
||||||
|
cx = CPUInfo[2];
|
||||||
|
dx = CPUInfo[3];
|
||||||
|
}
|
||||||
|
#elif defined(GCC_COMPATIBLE)
|
||||||
|
__get_cpuid(1, &ax, &bx, &cx, &dx);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
has_sse1 = (dx & sse1_flag) || false;
|
||||||
|
has_sse2 = (dx & sse2_flag) || false;
|
||||||
|
has_sse3 = (cx & sse3_flag) || false;
|
||||||
|
has_ssse3 = (cx & ssse3_flag) || false;
|
||||||
|
has_sse41 = (cx & sse41_flag) || false;
|
||||||
|
has_sse42 = (cx & sse42_flag) || false;
|
||||||
|
has_avx = (cx & avx_flag) || false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const hsCpuId& hsCpuId::instance()
|
const hsCpuId& hsCpuId::instance()
|
||||||
|
@ -98,7 +98,7 @@ struct hsWide {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const hsWide kPosInfinity64 = { kPosInfinity32, 0xffffffff };
|
const hsWide kPosInfinity64 = { kPosInfinity32, 0xffffffff };
|
||||||
const hsWide kNegInfinity64 = { kNegInfinity32, 0 };
|
const hsWide kNegInfinity64 = { static_cast<int32_t>(kNegInfinity32), 0 };
|
||||||
|
|
||||||
/////////////////////// Inline implementations ///////////////////////
|
/////////////////////// Inline implementations ///////////////////////
|
||||||
|
|
||||||
|
@ -361,7 +361,7 @@ plStringBuffer<wchar_t> plString::ToWchar() const
|
|||||||
plStringBuffer<uint16_t> utf16 = ToUtf16();
|
plStringBuffer<uint16_t> utf16 = ToUtf16();
|
||||||
return *reinterpret_cast<plStringBuffer<wchar_t>*>(&utf16);
|
return *reinterpret_cast<plStringBuffer<wchar_t>*>(&utf16);
|
||||||
#else
|
#else
|
||||||
plStringBuffer<uint16_t> result;
|
plStringBuffer<wchar_t> result;
|
||||||
if (IsEmpty())
|
if (IsEmpty())
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
@ -527,7 +527,7 @@ plString plString::IFormat(const char *fmt, va_list vptr)
|
|||||||
}
|
}
|
||||||
} else if (chars >= 256) {
|
} else if (chars >= 256) {
|
||||||
va_copy(vptr, vptr_save);
|
va_copy(vptr, vptr_save);
|
||||||
std::auto_ptr<char> bigbuffer(new char[chars+1]);
|
std::unique_ptr<char> bigbuffer(new char[chars+1]);
|
||||||
vsnprintf(bigbuffer.get(), chars+1, fmt, vptr);
|
vsnprintf(bigbuffer.get(), chars+1, fmt, vptr);
|
||||||
return plString::FromUtf8(bigbuffer.get(), chars);
|
return plString::FromUtf8(bigbuffer.get(), chars);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user