diff --git a/third_party/externals/zlib/cpu_features.c b/third_party/externals/zlib/cpu_features.c index 70f01beebe30b59b2607a2b6d9dbe048e957c45d..5be4144cab722f5306e404c0f4d90e29ae3c3754 100644 --- a/third_party/externals/zlib/cpu_features.c +++ b/third_party/externals/zlib/cpu_features.c @@ -31,13 +31,13 @@ int ZLIB_INTERNAL x86_cpu_enable_simd = 0; #ifndef CPU_NO_SIMD -#if defined(ARMV8_OS_ANDROID) || defined(ARMV8_OS_LINUX) || defined(ARMV8_OS_FUCHSIA) +#if defined(ARMV8_OS_ANDROID) || defined(ARMV8_OS_LINUX) || defined(ARMV8_OS_FUCHSIA) || defined(ARMV8_OS_OHOS) #include #endif #if defined(ARMV8_OS_ANDROID) #include -#elif defined(ARMV8_OS_LINUX) +#elif (defined(ARMV8_OS_LINUX) || defined(ARMV8_OS_OHOS)) && __has_include() && __has_include() #include #include #elif defined(ARMV8_OS_FUCHSIA) @@ -56,7 +56,7 @@ int ZLIB_INTERNAL x86_cpu_enable_simd = 0; static void _cpu_check_features(void); #endif -#if defined(ARMV8_OS_ANDROID) || defined(ARMV8_OS_LINUX) || defined(ARMV8_OS_MACOS) || defined(ARMV8_OS_FUCHSIA) || defined(X86_NOT_WINDOWS) +#if defined(ARMV8_OS_ANDROID) || defined(ARMV8_OS_LINUX) || defined(ARMV8_OS_MACOS) || defined(ARMV8_OS_FUCHSIA) || defined(X86_NOT_WINDOWS) || defined(ARMV8_OS_OHOS) #if !defined(ARMV8_OS_MACOS) // _cpu_check_features() doesn't need to do anything on mac/arm since all // features are known at build time, so don't call it. @@ -104,7 +104,7 @@ static void _cpu_check_features(void) uint64_t features = android_getCpuFeatures(); arm_cpu_enable_crc32 = !!(features & ANDROID_CPU_ARM_FEATURE_CRC32); arm_cpu_enable_pmull = !!(features & ANDROID_CPU_ARM_FEATURE_PMULL); -#elif defined(ARMV8_OS_LINUX) && defined(__aarch64__) +#elif (defined(ARMV8_OS_LINUX) || defined(ARMV8_OS_OHOS)) && defined(__aarch64__) && __has_include() && __has_include() unsigned long features = getauxval(AT_HWCAP); arm_cpu_enable_crc32 = !!(features & HWCAP_CRC32); arm_cpu_enable_pmull = !!(features & HWCAP_PMULL); diff --git a/third_party/zlib/BUILD.gn b/third_party/zlib/BUILD.gn index abe74d025d2f67f38577234f89083f21d1170d4d..a5a0fc079bbbb1c1fb5254dc506ba6719e2923eb 100644 --- a/third_party/zlib/BUILD.gn +++ b/third_party/zlib/BUILD.gn @@ -44,8 +44,10 @@ if (skia_use_system_zlib) { # iOS@ARM is a special case where we always have NEON but don't check # for crypto extensions. defines += [ "ARM_OS_IOS" ] - } # else { - # assert(false, "Unsupported ARM OS") + } else if (is_ohos) { + defines += [ "ARMV8_OS_OHOS" ] + } # else { + # assert(false, "Unsupported ARM OS") # } } @@ -57,6 +59,10 @@ if (skia_use_system_zlib) { } } + config("zlib_crc32_config") { + defines = [ "CRC32_ARMV8_CRC32" ] + } + source_set("zlib_adler32_simd") { visibility = [ ":*" ] configs += [ ":zlib_simd_config" ] @@ -80,7 +86,7 @@ if (skia_use_system_zlib) { # "All implementations of the ARMv8.1 architecture are required to # implement the CRC32* instructions. These are optional in ARMv8.0." if (!is_ios && use_arm_neon_optimizations) { - defines = [ "CRC32_ARMV8_CRC32" ] + public_configs = [ ":zlib_crc32_config" ] # An ARMv7 GCC build will fail to compile without building this target # for ARMv8-a+crc and letting runtime cpu detection select the correct