* Protect including sys/auxv.h in all relevant files with the new preprocessor define
* Test for both existence of both sys/auxv.h and getauxval() with both cmake and configure
#
# Check for standard/system includes
#
+check_include_file(sys/auxv.h HAVE_SYS_AUXV_H)
+if(HAVE_SYS_AUXV_H)
+ add_definitions(-DHAVE_SYS_AUXV_H)
+endif()
check_include_file(sys/sdt.h HAVE_SYS_SDT_H)
if(HAVE_SYS_SDT_H)
add_definitions(-DHAVE_SYS_SDT_H)
endif()
endif()
elseif(BASEARCH_S360_FOUND)
- if(WITH_CRC32_VX)
+ check_s390_intrinsics()
+ if(HAVE_S390_INTRIN)
add_definitions(-DS390_FEATURES)
list(APPEND ZLIB_ARCH_HDRS ${ARCHDIR}/s390_features.h)
list(APPEND ZLIB_ARCH_SRCS ${ARCHDIR}/s390_features.c)
#include "../../zbuild.h"
-#if defined(__linux__)
+#if defined(__linux__) && defined(HAVE_SYS_AUXV_H)
# include <sys/auxv.h>
# ifdef ARM_ASM_HWCAP
# include <asm/hwcap.h>
/* power_features.c - POWER feature check
* Copyright (C) 2020 Matheus Castanho <msc@linux.ibm.com>, IBM
- * Copyright (C) 2021 Mika T. Lindqvist <postmaster@raasu.org>
+ * Copyright (C) 2021-2022 Mika T. Lindqvist <postmaster@raasu.org>
* For conditions of distribution and use, see copyright notice in zlib.h
*/
-#include <sys/auxv.h>
+#ifdef HAVE_SYS_AUXV_H
+# include <sys/auxv.h>
+#endif
#include "../../zbuild.h"
#include "power_features.h"
#include "../../zbuild.h"
#include "s390_features.h"
-#include <sys/auxv.h>
+#ifdef HAVE_SYS_AUXV_H
+# include <sys/auxv.h>
+#endif
-Z_INTERNAL int s390_cpu_has_vx;
+Z_INTERNAL int s390_cpu_has_vx = 0;
void Z_INTERNAL s390_check_features(void) {
+#ifdef S390_FEATURES
s390_cpu_has_vx = getauxval(AT_HWCAP) & HWCAP_S390_VX;
+#endif
}
set(CMAKE_REQUIRED_FLAGS)
endmacro()
+macro(check_s390_intrinsics)
+ check_c_source_compiles(
+ "#include <sys/auxv.h>
+ int main() {
+ return (getauxval(AT_HWCAP) & HWCAP_S390_VX);
+ }"
+ HAVE_S390_INTRIN
+ )
+endmacro()
+
macro(check_sse2_intrinsics)
if(CMAKE_C_COMPILER_ID MATCHES "Intel")
if(CMAKE_HOST_UNIX OR APPLE)
echo "Checking for strerror... No." | tee -a configure.log
fi
+# check for getauxval() for architecture feature detection at run-time
+cat > $test.c <<EOF
+#include <sys/auxv.h>
+int main() { return getauxval(0); }
+EOF
+if try $CC $CFLAGS -o $test $test.c $LDSHAREDLIBC; then
+ echo "Checking for getauxval() in sys/auxv.h... Yes." | tee -a configure.log
+ CFLAGS="${CFLAGS} -DHAVE_SYS_AUXV_H"
+ SFLAGS="${SFLAGS} -DHAVE_SYS_AUXV_H"
+else
+ echo "Checking for getauxval() in sys/auxv.h... No." | tee -a configure.log
+fi
+
# We need to remove consigured files (zconf.h etc) from source directory if building outside of it
if [ "$SRCDIR" != "$BUILDDIR" ]; then
rm -f $SRCDIR/zconf${SUFFIX}.h