Commit 28d90591 authored by Tom Tan's avatar Tom Tan Committed by Commit Bot

Initialize zlib processor feature flags for Windows ARM64

Bug: 893460
Change-Id: I69914310f35a1b21159da701447651aba4f1b888
Reviewed-on: https://chromium-review.googlesource.com/c/1334934
Commit-Queue: Tom Tan <Tom.Tan@microsoft.com>
Reviewed-by: default avatarChris Blume <cblume@chromium.org>
Cr-Commit-Position: refs/heads/master@{#608107}
parent 0f4e2cd9
...@@ -7,6 +7,11 @@ ...@@ -7,6 +7,11 @@
#include "arm_features.h" #include "arm_features.h"
#include "zutil.h" #include "zutil.h"
int ZLIB_INTERNAL arm_cpu_enable_crc32 = 0;
int ZLIB_INTERNAL arm_cpu_enable_pmull = 0;
#if !defined(_MSC_VER)
#include <pthread.h> #include <pthread.h>
#include <stdint.h> #include <stdint.h>
...@@ -19,9 +24,6 @@ ...@@ -19,9 +24,6 @@
#error ### No ARM CPU features detection in your platform/OS #error ### No ARM CPU features detection in your platform/OS
#endif #endif
int ZLIB_INTERNAL arm_cpu_enable_crc32 = 0;
int ZLIB_INTERNAL arm_cpu_enable_pmull = 0;
static pthread_once_t cpu_check_inited_once = PTHREAD_ONCE_INIT; static pthread_once_t cpu_check_inited_once = PTHREAD_ONCE_INIT;
static void init_arm_features(void) static void init_arm_features(void)
...@@ -58,3 +60,31 @@ void ZLIB_INTERNAL arm_check_features(void) ...@@ -58,3 +60,31 @@ void ZLIB_INTERNAL arm_check_features(void)
{ {
pthread_once(&cpu_check_inited_once, init_arm_features); pthread_once(&cpu_check_inited_once, init_arm_features);
} }
#else
#include <windows.h>
static BOOL CALLBACK _arm_check_features(PINIT_ONCE once,
PVOID param,
PVOID *context);
static INIT_ONCE cpu_check_inited_once = INIT_ONCE_STATIC_INIT;
void ZLIB_INTERNAL arm_check_features(void)
{
InitOnceExecuteOnce(&cpu_check_inited_once, _arm_check_features,
NULL, NULL);
}
static BOOL CALLBACK _arm_check_features(PINIT_ONCE once,
PVOID param,
PVOID *context)
{
if (IsProcessorFeaturePresent(PF_ARM_V8_CRC32_INSTRUCTIONS_AVAILABLE))
arm_cpu_enable_crc32 = 1;
if (IsProcessorFeaturePresent(PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE))
arm_cpu_enable_pmull = 1;
return TRUE;
}
#endif /* _MSC_VER */
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