| Index: third_party/zlib/x86.c
|
| diff --git a/third_party/zlib/x86.c b/third_party/zlib/x86.c
|
| index 0649306f2f0ffd39bd26bd31346919593cffa55c..e6532fd10ddb46fd0305287d158cc888fc6faa8c 100644
|
| --- a/third_party/zlib/x86.c
|
| +++ b/third_party/zlib/x86.c
|
| @@ -56,43 +56,21 @@ static void _x86_check_features(void)
|
| #else
|
| #include <intrin.h>
|
| #include <windows.h>
|
| -#include <stdint.h>
|
|
|
| -static volatile int32_t once_control = 0;
|
| -static void _x86_check_features(void);
|
| -static int fake_pthread_once(volatile int32_t *once_control,
|
| - void (*init_routine)(void));
|
| +static BOOL CALLBACK _x86_check_features(PINIT_ONCE once,
|
| + PVOID param,
|
| + PVOID *context);
|
| +static INIT_ONCE cpu_check_inited_once = INIT_ONCE_STATIC_INIT;
|
|
|
| void x86_check_features(void)
|
| {
|
| - fake_pthread_once(&once_control, _x86_check_features);
|
| -}
|
| -
|
| -/* Copied from "perftools_pthread_once" in tcmalloc */
|
| -static int fake_pthread_once(volatile int32_t *once_control,
|
| - void (*init_routine)(void)) {
|
| - // Try for a fast path first. Note: this should be an acquire semantics read
|
| - // It is on x86 and x64, where Windows runs.
|
| - if (*once_control != 1) {
|
| - while (1) {
|
| - switch (InterlockedCompareExchange(once_control, 2, 0)) {
|
| - case 0:
|
| - init_routine();
|
| - InterlockedExchange(once_control, 1);
|
| - return 0;
|
| - case 1:
|
| - // The initializer has already been executed
|
| - return 0;
|
| - default:
|
| - // The initializer is being processed by another thread
|
| - SwitchToThread();
|
| - }
|
| - }
|
| - }
|
| - return 0;
|
| + InitOnceExecuteOnce(&cpu_check_inited_once, _x86_check_features,
|
| + NULL, NULL);
|
| }
|
|
|
| -static void _x86_check_features(void)
|
| +static BOOL CALLBACK _x86_check_features(PINIT_ONCE once,
|
| + PVOID param,
|
| + PVOID *context)
|
| {
|
| int x86_cpu_has_sse2;
|
| int x86_cpu_has_sse42;
|
| @@ -108,5 +86,6 @@ static void _x86_check_features(void)
|
| x86_cpu_enable_simd = x86_cpu_has_sse2 &&
|
| x86_cpu_has_sse42 &&
|
| x86_cpu_has_pclmulqdq;
|
| + return TRUE;
|
| }
|
| #endif /* _MSC_VER */
|
|
|