gsdx: Use char array instead of string for name

"static string str;" causes a SIGILL signal on a "Nehalem" (SSE4.2)
QEMU VM when compiled with GCC 6.1.1.
This commit is contained in:
Jonathan Li 2016-07-23 23:19:30 +01:00
parent 46ba9aa117
commit 7e30d16797
1 changed files with 50 additions and 48 deletions

View File

@ -35,58 +35,60 @@
const char* GSUtil::GetLibName() const char* GSUtil::GetLibName()
{ {
// TODO: critsec // The following ifdef mess is courtesy of "static string str;"
// being optimised by GCC to be unusable by older CPUs. Enjoy!
static char name[255];
static string str; snprintf(name, sizeof(name), "GSdx "
if(str.empty()) #ifdef _WIN32
{ "%lld "
str = "GSdx"; #endif
#ifdef _M_AMD64
"64-bit "
#endif
#ifdef __INTEL_COMPILER
"(Intel C++ %d.%02d %s)",
#elif _MSC_VER
"(MSVC %d.%02d %s)",
#elif __clang__
"(clang %d.%d.%d %s)",
#elif __GNUC__
"(GCC %d.%d.%d %s)",
#else
"(%s)",
#endif
#ifdef _WIN32
SVN_REV,
#endif
#ifdef __INTEL_COMPILER
__INTEL_COMPILER / 100, __INTEL_COMPILER % 100,
#elif _MSC_VER
_MSC_VER / 100, _MSC_VER % 100,
#elif __clang__
__clang_major__, __clang_minor__, __clang_patchlevel__,
#elif __GNUC__
__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__,
#endif
#ifdef _WIN32 #if _M_SSE >= 0x501
str += format(" %lld", SVN_REV); "AVX2"
if(SVN_MODS) str += "m"; #elif _M_SSE >= 0x500
#endif "AVX"
#elif _M_SSE >= 0x402
"SSE4.2"
#elif _M_SSE >= 0x401
"SSE4.1"
#elif _M_SSE >= 0x301
"SSSE3"
#elif _M_SSE >= 0x200
"SSE2"
#elif _M_SSE >= 0x100
"SSE"
#endif
);
#ifdef _M_AMD64 return name;
str += " 64-bit";
#endif
list<string> sl;
#ifdef __INTEL_COMPILER
sl.push_back(format("Intel C++ %d.%02d", __INTEL_COMPILER / 100, __INTEL_COMPILER % 100));
#elif _MSC_VER
sl.push_back(format("MSVC %d.%02d", _MSC_VER / 100, _MSC_VER % 100));
#elif __GNUC__
sl.push_back(format("GCC %d.%d.%d", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__));
#endif
#if _M_SSE >= 0x501
sl.push_back("AVX2");
#elif _M_SSE >= 0x500
sl.push_back("AVX");
#elif _M_SSE >= 0x402
sl.push_back("SSE42");
#elif _M_SSE >= 0x401
sl.push_back("SSE41");
#elif _M_SSE >= 0x301
sl.push_back("SSSE3");
#elif _M_SSE >= 0x200
sl.push_back("SSE2");
#elif _M_SSE >= 0x100
sl.push_back("SSE");
#endif
for(list<string>::iterator i = sl.begin(); i != sl.end(); )
{
if(i == sl.begin()) str += " (";
str += *i;
str += ++i != sl.end() ? ", " : ")";
}
}
return str.c_str();
} }
static class GSUtilMaps static class GSUtilMaps