Skip to content

Commit

Permalink
Updated x86 arm power_pc check feature using constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
kitaisreal committed Apr 15, 2021
1 parent 16b42c7 commit 28dfdaa
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 24 deletions.
2 changes: 1 addition & 1 deletion arch/power/power.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 0 additions & 2 deletions arch/power/power.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,4 @@

extern int power_cpu_has_arch_2_07;

void Z_INTERNAL power_check_features(void);

#endif /* POWER_H_ */
1 change: 0 additions & 1 deletion crc32.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
20 changes: 0 additions & 20 deletions functable.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 28dfdaa

Please sign in to comment.