From 58ca089c9eebe47d62402067a1392a016a3d9058 Mon Sep 17 00:00:00 2001 From: Andreas Krebbel Date: Thu, 4 Jul 2024 15:17:36 +0200 Subject: [PATCH] S/390: Use getauxval to fix #560 --- src/libm/CMakeLists.txt | 6 ------ src/libm/disps390x_128.c.org | 11 +++++++++-- src/libm/tryvxe2.c | 8 -------- 3 files changed, 9 insertions(+), 16 deletions(-) delete mode 100644 src/libm/tryvxe2.c diff --git a/src/libm/CMakeLists.txt b/src/libm/CMakeLists.txt index a34841e9..1bd2ab6f 100644 --- a/src/libm/CMakeLists.txt +++ b/src/libm/CMakeLists.txt @@ -833,12 +833,6 @@ if (SLEEF_ARCH_S390X) add_dependencies(disps390x_128_obj disps390x_128.c_generated renamedsp128.h_generated ${TARGET_HEADERS}) target_sources(${TARGET_LIBSLEEF} PRIVATE $) - if(COMPILER_SUPPORTS_VXE2) - add_library(tryvxe2_obj OBJECT tryvxe2.c) - target_compile_options(tryvxe2_obj PRIVATE ${FLAGS_ENABLE_VXE2}) - set_target_properties(tryvxe2_obj PROPERTIES ${COMMON_TARGET_PROPERTIES}) - target_sources(${TARGET_LIBSLEEF} PRIVATE $) - endif() endif(SLEEF_ARCH_S390X) # -------------------------------------------------------------------- diff --git a/src/libm/disps390x_128.c.org b/src/libm/disps390x_128.c.org index 1c92af2e..2301e156 100644 --- a/src/libm/disps390x_128.c.org +++ b/src/libm/disps390x_128.c.org @@ -7,6 +7,7 @@ #include #include #include +#include #include "misc.h" @@ -15,9 +16,15 @@ #include "dispatcher.h" +static int cpuSupportsVXE2() { + static int ret = -1; + if (ret == -1) + ret = !!(getauxval(AT_HWCAP) & HWCAP_S390_VXRS_EXT2); + return ret; +} + #ifdef ENABLE_VXE2 -void sleef_tryVXE2(); -#define SUBST_IF_EXT1(funcvxe2) if (cpuSupportsExt(sleef_tryVXE2)) p = funcvxe2; +#define SUBST_IF_EXT1(funcvxe2) if (cpuSupportsVXE2()) p = funcvxe2; #else #define SUBST_IF_EXT1(funcvxe2) #endif diff --git a/src/libm/tryvxe2.c b/src/libm/tryvxe2.c deleted file mode 100644 index b4a73a9f..00000000 --- a/src/libm/tryvxe2.c +++ /dev/null @@ -1,8 +0,0 @@ -#include - -__vector float sleef_cpuid_VXE2; -__vector int sleef_cpuid_VXE1; - -void sleef_tryVXE2() { - sleef_cpuid_VXE2 = vec_float(sleef_cpuid_VXE1); -}