Commit 5af76cac authored by Kenton Varda's avatar Kenton Varda Committed by GitHub

Merge pull request #365 from mark-grimes/msvcThreadFix

Fixes for windows
parents ce99c604 90c39c42
......@@ -1606,7 +1606,7 @@ struct WireHelpers {
if (dataSize % BYTES_PER_WORD != 0 * BYTES) {
//Zero-pad the data if it didn't use the entire last word
byte* padStart = reinterpret_cast<byte*>(ptr) + (dataSize / BYTES);
bzero(padStart, (BYTES_PER_WORD * WORDS - (dataSize % BYTES_PER_WORD)) / BYTES);
memset(padStart, 0, (BYTES_PER_WORD * WORDS - (dataSize % BYTES_PER_WORD)) / BYTES);
}
}
......
......@@ -24,6 +24,7 @@
#if _WIN32
#include <windows.h>
#include "windows-sanity.h"
#else
#include <pthread.h>
#include <signal.h>
......@@ -42,7 +43,7 @@ Thread::~Thread() noexcept(false) {
if (!detached) {
KJ_ASSERT(WaitForSingleObject(threadHandle, INFINITE) != WAIT_FAILED);
KJ_IF_MAYBE(e, exception) {
KJ_IF_MAYBE(e, state->exception) {
kj::throwRecoverableException(kj::mv(*e));
}
}
......@@ -125,8 +126,7 @@ void* Thread::runThread(void* ptr) {
void Thread::ThreadState::unref() {
#if _MSC_VER
if (_InterlockedDecrement_rel(&refcount)) {
_ReadBarrier();
if (_InterlockedDecrement(&refcount)) {
#else
if (__atomic_sub_fetch(&refcount, 1, __ATOMIC_RELEASE) == 0) {
__atomic_thread_fence(__ATOMIC_ACQUIRE);
......
......@@ -59,7 +59,7 @@ private:
Function<void()> func;
kj::Maybe<kj::Exception> exception;
int refcount;
unsigned int refcount;
// Owned by the parent thread and the child thread.
void unref();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment