Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(640)

Unified Diff: third_party/zlib/x86.c

Issue 1711683003: zlib: Remove Windows XP workaround for CPU feature detection (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 80 char tidy up Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 */
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698