From dfb67134dc029f0ed6001dfc8c0e2a04e136ffa6 Mon Sep 17 00:00:00 2001 From: David Benjamin Date: Fri, 8 May 2015 12:45:40 -0400 Subject: [PATCH] Define CRYPTO_once_t as LONG on Windows. This is used with a platform API, so it should use the corresponding platform type, saving us the size assert. It's ever defined in an internal header, so we can freely use windows.h and friends. Change-Id: Idc979309436adcf54524c835ddc2c98c3870d2e2 Reviewed-on: https://boringssl-review.googlesource.com/4680 Reviewed-by: Adam Langley --- crypto/internal.h | 2 +- crypto/thread_win.c | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/crypto/internal.h b/crypto/internal.h index 9cb8573c..a4cd3d8a 100644 --- a/crypto/internal.h +++ b/crypto/internal.h @@ -336,7 +336,7 @@ static inline int constant_time_select_int(unsigned int mask, int a, int b) { typedef pthread_once_t CRYPTO_once_t; #define CRYPTO_ONCE_INIT PTHREAD_ONCE_INIT #else -typedef int32_t CRYPTO_once_t; +typedef LONG CRYPTO_once_t; #define CRYPTO_ONCE_INIT 0 #endif diff --git a/crypto/thread_win.c b/crypto/thread_win.c index 7a4f9bcb..fc8e50a1 100644 --- a/crypto/thread_win.c +++ b/crypto/thread_win.c @@ -32,9 +32,8 @@ OPENSSL_COMPILE_ASSERT(sizeof(CRYPTO_MUTEX) >= sizeof(CRITICAL_SECTION), CRYPTO_MUTEX_too_small); static void run_once(CRYPTO_once_t *in_once, void (*init)(void *), void *arg) { - volatile LONG *once = (LONG*) in_once; + volatile LONG *once = in_once; - assert(sizeof(LONG) == sizeof(CRYPTO_once_t)); /* Values must be aligned. */ assert((((uintptr_t) once) & 3) == 0);