7 #if CRYPTOPP_MSC_VERSION 8 # pragma warning(disable: 4297) 11 #ifndef CRYPTOPP_IMPORTS 13 #if !defined(NO_OS_DEPENDENCE) && defined(THREADS_AVAILABLE) 18 #define WIN32_LEAN_AND_MEAN 24 ThreadLocalStorage::Err::Err(const
std::
string& operation,
int error)
29 ThreadLocalStorage::ThreadLocalStorage()
34 if (m_index == TLS_OUT_OF_INDEXES)
35 throw Err(
"TlsAlloc", GetLastError());
38 int error = pthread_key_create(&m_index, NULL);
41 throw Err(
"pthread_key_create", error);
47 #ifdef CRYPTOPP_UNCAUGHT_EXCEPTION_AVAILABLE 48 if (!std::uncaught_exception())
54 int rc = TlsFree(m_index);
57 throw Err(
"TlsFree", GetLastError());
61 int error = pthread_key_delete(m_index);
64 throw Err(
"pthread_key_delete", error);
67 #ifndef CRYPTOPP_UNCAUGHT_EXCEPTION_AVAILABLE 74 void ThreadLocalStorage::SetValue(
void *value)
77 if (!TlsSetValue(m_index, value))
78 throw Err(
"TlsSetValue", GetLastError());
80 int error = pthread_setspecific(m_index, value);
82 throw Err(
"pthread_key_getspecific", error);
86 void *ThreadLocalStorage::GetValue()
const 89 void *result = TlsGetValue(m_index);
90 const DWORD dwRet = GetLastError();
93 if (!result && dwRet != NO_ERROR)
94 throw Err(
"TlsGetValue", dwRet);
98 void *result = pthread_getspecific(m_index);
105 #endif // THREADS_AVAILABLE 106 #endif // CRYPTOPP_IMPORTS Base class for all exceptions thrown by the library.
bool error(const char *fmt, const Args &...args)
The operating system reported an error.
#define NAMESPACE_BEGIN(x)
Library configuration file.
std::hash for asio::adress
#define CRYPTOPP_ASSERT(exp)
std::string IntToString(T value, unsigned int base=10)
Converts a value to a string.