diff --git a/include/uv-private/uv-win.h b/include/uv-private/uv-win.h index 80f9faf28..132339abb 100644 --- a/include/uv-private/uv-win.h +++ b/include/uv-private/uv-win.h @@ -219,14 +219,11 @@ typedef union { } fallback_; } uv_rwlock_t; -#define UV_ONCE_INIT { 0, NULL, NULL } +#define UV_ONCE_INIT { 0, NULL } typedef struct uv_once_s { unsigned char ran; - /* The actual event handle must be aligned to sizeof(HANDLE), so in */ - /* practice it might overlap padding a little. */ HANDLE event; - HANDLE padding; } uv_once_t; /* Platform-specific definitions for uv_spawn support. */ diff --git a/src/win/thread.c b/src/win/thread.c index aecfaf4f8..cb2ba4ec6 100644 --- a/src/win/thread.c +++ b/src/win/thread.c @@ -60,11 +60,6 @@ static NOINLINE void uv__once_inner(uv_once_t* guard, void (*callback)(void)) { DWORD result; HANDLE existing_event, created_event; - HANDLE* event_ptr; - - /* Fetch and align event_ptr */ - event_ptr = (HANDLE*) (((uintptr_t) &guard->event + (sizeof(HANDLE) - 1)) & - ~(sizeof(HANDLE) - 1)); created_event = CreateEvent(NULL, 1, 0, NULL); if (created_event == 0) { @@ -72,7 +67,7 @@ static NOINLINE void uv__once_inner(uv_once_t* guard, uv_fatal_error(GetLastError(), "CreateEvent"); } - existing_event = InterlockedCompareExchangePointer(event_ptr, + existing_event = InterlockedCompareExchangePointer(&guard->event, created_event, NULL);