Skip to content

Commit

Permalink
Merge pull request #184 from VerusCoin/dev
Browse files Browse the repository at this point in the history
Applying Mingw thread.local storage bug workaround
  • Loading branch information
Asherda authored Jan 1, 2019
2 parents d2c36e4 + 095711b commit 64c39e8
Showing 1 changed file with 14 additions and 19 deletions.
33 changes: 14 additions & 19 deletions src/crypto/verus_clhash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,21 @@
thread_local thread_specific_ptr verusclhasher_key;
thread_local thread_specific_ptr verusclhasher_descr;

//#ifdef _WIN32
#ifdef _WIN32
// attempt to workaround horrible mingw/gcc destructor bug on Windows, which passes garbage in the this pointer
// we use the opportunity of control here to clean up all of our tls variables. we could keep a list, but this is a quick hack
//thread_specific_ptr::~thread_specific_ptr() {
// if (verusclhasher_key.ptr)
// {
// verusclhasher_key.reset();
// }
// if (verusclhasher_descr.ptr)
// {
// verusclhasher_descr.reset();
// }
//}
//#endif

int __cpuverusoptimized = 0x80;
// we use the opportunity of control here to clean up all of our tls variables. we could keep a list, but this is a safe,
// functional hack
thread_specific_ptr::~thread_specific_ptr() {
if (verusclhasher_key.ptr)
{
verusclhasher_key.reset();
}
if (verusclhasher_descr.ptr)
{
verusclhasher_descr.reset();
}
}
#endif

// multiply the length and the some key, no modulo
static inline __attribute__((always_inline)) __m128i lazyLengthHash(uint64_t keylength, uint64_t length) {
Expand Down Expand Up @@ -545,10 +544,6 @@ uint64_t verusclhash(void * random, const unsigned char buf[64], uint64_t keyMas
return precompReduction64(acc);
}

#ifdef __WIN32
#define posix_memalign(p, a, s) (((*(p)) = _aligned_malloc((s), (a))), *(p) ?0 :errno)
#endif

void *alloc_aligned_buffer(uint64_t bufSize)
{
void *answer = NULL;
Expand Down

0 comments on commit 64c39e8

Please sign in to comment.