mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-22 21:09:52 +00:00
Remove unnecessary use of thread local storage
This commit is contained in:
parent
835b819faa
commit
d9edc68966
@ -475,11 +475,12 @@ add_library(Common STATIC
|
||||
Common/MemArena.h
|
||||
Common/MemoryUtil.cpp
|
||||
Common/MemoryUtil.h
|
||||
Common/Misc.cpp
|
||||
Common/OSVersion.cpp
|
||||
Common/OSVersion.h
|
||||
Common/StringUtils.cpp
|
||||
Common/StringUtils.h
|
||||
Common/SysError.h
|
||||
Common/SysError.cpp
|
||||
Common/ThreadPools.cpp
|
||||
Common/ThreadPools.h
|
||||
Common/ThreadSafeList.h
|
||||
|
@ -415,6 +415,7 @@
|
||||
<ClInclude Include="stdafx.h" />
|
||||
<ClInclude Include="StringUtils.h" />
|
||||
<ClInclude Include="Swap.h" />
|
||||
<ClInclude Include="SysError.h" />
|
||||
<ClInclude Include="ThreadPools.h" />
|
||||
<ClInclude Include="ThreadSafeList.h" />
|
||||
<ClInclude Include="Thunk.h" />
|
||||
@ -501,7 +502,7 @@
|
||||
<ClCompile Include="MemArenaDarwin.cpp" />
|
||||
<ClCompile Include="MemoryUtil.cpp" />
|
||||
<ClCompile Include="MipsEmitter.cpp" />
|
||||
<ClCompile Include="Misc.cpp" />
|
||||
<ClCompile Include="SysError.cpp" />
|
||||
<ClCompile Include="OSVersion.cpp" />
|
||||
<ClCompile Include="stdafx.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
|
||||
|
@ -96,6 +96,7 @@
|
||||
<ClInclude Include="FakeEmitter.h" />
|
||||
<ClInclude Include="ByteSwap.h" />
|
||||
<ClInclude Include="Buffer.h" />
|
||||
<ClInclude Include="SysError.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="stdafx.cpp" />
|
||||
@ -105,7 +106,6 @@
|
||||
<ClCompile Include="FileUtil.cpp" />
|
||||
<ClCompile Include="LogManager.cpp" />
|
||||
<ClCompile Include="MemoryUtil.cpp" />
|
||||
<ClCompile Include="Misc.cpp" />
|
||||
<ClCompile Include="StringUtils.cpp" />
|
||||
<ClCompile Include="Thunk.cpp" />
|
||||
<ClCompile Include="Timer.cpp" />
|
||||
@ -164,6 +164,7 @@
|
||||
<ClCompile Include="TimeUtil.cpp" />
|
||||
<ClCompile Include="Log.cpp" />
|
||||
<ClCompile Include="Buffer.cpp" />
|
||||
<ClCompile Include="SysError.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Filter Include="Crypto">
|
||||
|
@ -78,11 +78,3 @@ inline u64 __rotr64(u64 x, unsigned int shift){
|
||||
#endif
|
||||
#define Crash() {__debugbreak();}
|
||||
#endif // WIN32 ndef
|
||||
|
||||
// Generic function to get last error message.
|
||||
// Call directly after the command or use the error num.
|
||||
// This function might change the error code.
|
||||
// Defined in Misc.cpp.
|
||||
const char *GetLastErrorMsg();
|
||||
const char *GetStringErrorMsg(int errCode);
|
||||
|
||||
|
@ -15,14 +15,11 @@
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
|
||||
#include "util/text/utf8.h"
|
||||
#include "Common.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#if defined(__APPLE__)
|
||||
#define __thread
|
||||
#endif
|
||||
#include "SysError.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "CommonWindows.h"
|
||||
@ -31,8 +28,7 @@
|
||||
// Generic function to get last error message.
|
||||
// Call directly after the command or use the error num.
|
||||
// This function might change the error code.
|
||||
const char *GetLastErrorMsg()
|
||||
{
|
||||
std::string GetLastErrorMsg() {
|
||||
#ifdef _WIN32
|
||||
return GetStringErrorMsg(GetLastError());
|
||||
#else
|
||||
@ -40,25 +36,26 @@ const char *GetLastErrorMsg()
|
||||
#endif
|
||||
}
|
||||
|
||||
const char *GetStringErrorMsg(int errCode) {
|
||||
std::string GetStringErrorMsg(int errCode) {
|
||||
static const size_t buff_size = 1023;
|
||||
|
||||
#ifdef _WIN32
|
||||
static thread_local wchar_t err_strw[buff_size] = {};
|
||||
wchar_t err_strw[buff_size] = {};
|
||||
|
||||
FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, errCode,
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||
err_strw, buff_size, NULL);
|
||||
|
||||
static thread_local char err_str[buff_size] = {};
|
||||
char err_str[buff_size] = {};
|
||||
snprintf(err_str, buff_size, "%s", ConvertWStringToUTF8(err_strw).c_str());
|
||||
return std::string(err_str);
|
||||
#else
|
||||
static thread_local char err_str[buff_size] = {};
|
||||
char err_str[buff_size] = {};
|
||||
|
||||
// Thread safe (XSI-compliant)
|
||||
if (strerror_r(errCode, err_str, buff_size) == 0) {
|
||||
return "Unknown error";
|
||||
}
|
||||
#endif
|
||||
|
||||
return err_str;
|
||||
#endif
|
||||
}
|
10
Common/SysError.h
Normal file
10
Common/SysError.h
Normal file
@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
// Generic function to get last error message.
|
||||
// Call directly after the command or use the error num.
|
||||
// This function might change the error code.
|
||||
// Defined in Misc.cpp.
|
||||
std::string GetLastErrorMsg();
|
||||
std::string GetStringErrorMsg(int errCode);
|
@ -20,11 +20,12 @@
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "Common/ByteSwap.h"
|
||||
#include "Common/CPUDetect.h"
|
||||
#include "Core/MIPS/MIPS.h"
|
||||
#include "Core/MIPS/MIPSCodeUtils.h"
|
||||
#include "Core/MIPS/ARM64/Arm64Jit.h"
|
||||
#include "Core/MIPS/ARM64/Arm64RegCache.h"
|
||||
#include "Common/CPUDetect.h"
|
||||
|
||||
using namespace MIPSAnalyst;
|
||||
|
||||
|
@ -420,6 +420,7 @@
|
||||
<ClInclude Include="..\..\Common\stdafx.h" />
|
||||
<ClInclude Include="..\..\Common\StringUtils.h" />
|
||||
<ClInclude Include="..\..\Common\Swap.h" />
|
||||
<ClInclude Include="..\..\Common\SysError.h" />
|
||||
<ClInclude Include="..\..\Common\ThreadPools.h" />
|
||||
<ClInclude Include="..\..\Common\ThreadSafeList.h" />
|
||||
<ClInclude Include="..\..\Common\Thunk.h" />
|
||||
@ -455,7 +456,7 @@
|
||||
<ClCompile Include="..\..\Common\MemoryUtil.cpp" />
|
||||
<ClCompile Include="..\..\Common\MipsCPUDetect.cpp" />
|
||||
<ClCompile Include="..\..\Common\MipsEmitter.cpp" />
|
||||
<ClCompile Include="..\..\Common\Misc.cpp" />
|
||||
<ClCompile Include="..\..\Common\SysError.cpp" />
|
||||
<ClCompile Include="..\..\Common\OSVersion.cpp" />
|
||||
<ClCompile Include="..\..\Common\stdafx.cpp" />
|
||||
<ClCompile Include="..\..\Common\StringUtils.cpp" />
|
||||
|
@ -28,7 +28,7 @@
|
||||
<ClCompile Include="..\..\Common\MemoryUtil.cpp" />
|
||||
<ClCompile Include="..\..\Common\MipsCPUDetect.cpp" />
|
||||
<ClCompile Include="..\..\Common\MipsEmitter.cpp" />
|
||||
<ClCompile Include="..\..\Common\Misc.cpp" />
|
||||
<ClCompile Include="..\..\Common\SysError.cpp" />
|
||||
<ClCompile Include="..\..\Common\OSVersion.cpp" />
|
||||
<ClCompile Include="..\..\Common\stdafx.cpp" />
|
||||
<ClCompile Include="..\..\Common\StringUtils.cpp" />
|
||||
@ -89,6 +89,7 @@
|
||||
<ClInclude Include="..\..\Common\stdafx.h" />
|
||||
<ClInclude Include="..\..\Common\StringUtils.h" />
|
||||
<ClInclude Include="..\..\Common\Swap.h" />
|
||||
<ClInclude Include="..\..\Common\SysError.h" />
|
||||
<ClInclude Include="..\..\Common\ThreadPools.h" />
|
||||
<ClInclude Include="..\..\Common\ThreadSafeList.h" />
|
||||
<ClInclude Include="..\..\Common\Thunk.h" />
|
||||
|
@ -221,10 +221,10 @@ EXEC_AND_LIB_FILES := \
|
||||
$(SRC)/Common/MemoryUtil.cpp \
|
||||
$(SRC)/Common/FileUtil.cpp \
|
||||
$(SRC)/Common/StringUtils.cpp \
|
||||
$(SRC)/Common/SysError.cpp \
|
||||
$(SRC)/Common/ThreadPools.cpp \
|
||||
$(SRC)/Common/Timer.cpp \
|
||||
$(SRC)/Common/TimeUtil.cpp \
|
||||
$(SRC)/Common/Misc.cpp \
|
||||
$(SRC)/GPU/Math3D.cpp \
|
||||
$(SRC)/GPU/GPU.cpp \
|
||||
$(SRC)/GPU/GPUCommon.cpp \
|
||||
|
@ -153,7 +153,7 @@ SOURCES_CXX += \
|
||||
$(COMMONDIR)/LogManager.cpp \
|
||||
$(COMMONDIR)/OSVersion.cpp \
|
||||
$(COMMONDIR)/MemoryUtil.cpp \
|
||||
$(COMMONDIR)/Misc.cpp \
|
||||
$(COMMONDIR)/SysError.cpp \
|
||||
$(COMMONDIR)/StringUtils.cpp \
|
||||
$(COMMONDIR)/Timer.cpp \
|
||||
$(COMMONDIR)/TimeUtil.cpp \
|
||||
|
Loading…
Reference in New Issue
Block a user