From 28dfdaa8a3c5add48dcaf56086a9306a357e6e6b Mon Sep 17 00:00:00 2001 From: Maksim Kita Date: Fri, 16 Apr 2021 00:17:26 +0300 Subject: [PATCH] Updated x86 arm power_pc check feature using constructor --- arch/power/power.c | 2 +- arch/power/power.h | 2 -- crc32.c | 1 - functable.c | 20 -------------------- 4 files changed, 1 insertion(+), 24 deletions(-) diff --git a/arch/power/power.c b/arch/power/power.c index f93b586d5..b277c2637 100644 --- a/arch/power/power.c +++ b/arch/power/power.c @@ -8,7 +8,7 @@ Z_INTERNAL int power_cpu_has_arch_2_07; -void Z_INTERNAL power_check_features(void) { +static void __attribute__((constructor)) power_check_features(void) { unsigned long hwcap2; hwcap2 = getauxval(AT_HWCAP2); diff --git a/arch/power/power.h b/arch/power/power.h index b36c26141..0bf0b1ec4 100644 --- a/arch/power/power.h +++ b/arch/power/power.h @@ -8,6 +8,4 @@ extern int power_cpu_has_arch_2_07; -void Z_INTERNAL power_check_features(void); - #endif /* POWER_H_ */ diff --git a/crc32.c b/crc32.c index 4b488e617..e18c0c223 100644 --- a/crc32.c +++ b/crc32.c @@ -181,7 +181,6 @@ Z_INTERNAL void crc_finalize(deflate_state *const s) { Z_INTERNAL void crc_reset(deflate_state *const s) { #ifdef X86_PCLMULQDQ_CRC - x86_check_features(); if (x86_cpu_has_pclmulqdq) { crc_fold_init(s); return; diff --git a/functable.c b/functable.c index f20123358..c3c3707ee 100644 --- a/functable.c +++ b/functable.c @@ -136,27 +136,11 @@ extern uint32_t longest_match_unaligned_avx2(deflate_state *const s, Pos cur_mat Z_INTERNAL Z_TLS struct functable_s functable; -Z_INTERNAL void cpu_check_features(void) -{ - static int features_checked = 0; - if (features_checked) - return; -#if defined(X86_FEATURES) - x86_check_features(); -#elif defined(ARM_FEATURES) - arm_check_features(); -#elif defined(POWER_FEATURES) - power_check_features(); -#endif - features_checked = 1; -} - /* stub functions */ Z_INTERNAL void insert_string_stub(deflate_state *const s, const uint32_t str, uint32_t count) { // Initialize default functable.insert_string = &insert_string_c; - cpu_check_features(); #ifdef X86_SSE42_CRC_HASH if (x86_cpu_has_sse42) @@ -186,7 +170,6 @@ Z_INTERNAL Pos quick_insert_string_stub(deflate_state *const s, const uint32_t s Z_INTERNAL void slide_hash_stub(deflate_state *s) { functable.slide_hash = &slide_hash_c; - cpu_check_features(); #ifdef X86_SSE2 # if !defined(__x86_64__) && !defined(_M_X64) && !defined(X86_NOCHECK_SSE2) @@ -214,7 +197,6 @@ Z_INTERNAL void slide_hash_stub(deflate_state *s) { Z_INTERNAL uint32_t adler32_stub(uint32_t adler, const unsigned char *buf, size_t len) { // Initialize default functable.adler32 = &adler32_c; - cpu_check_features(); #ifdef ARM_NEON_ADLER32 # ifndef ARM_NOCHECK_NEON @@ -378,8 +360,6 @@ Z_INTERNAL uint32_t crc32_stub(uint32_t crc, const unsigned char *buf, uint64_t "crc32_z takes size_t but internally we have a uint64_t len"); /* return a function pointer for optimized arches here after a capability test */ - cpu_check_features(); - if (use_byfour) { #if BYTE_ORDER == LITTLE_ENDIAN functable.crc32 = crc32_little;