* POWER8/9 feature checks were enabled even if the toolchain didn't support AT_HWCAP2
* Add detection if we need to include <linux/auxvec.h>
endif()
check_include_file(unistd.h HAVE_UNISTD_H)
+#
+# Check for Linux includes
+#
+check_include_file(linux/auxvec.h HAVE_LINUX_AUXVEC_H)
+if(HAVE_LINUX_AUXVEC_H)
+ add_definitions(-DHAVE_LINUX_AUXVEC_H)
+endif()
+
#
# Check to see if we have large file support
#
if(WITH_POWER9)
check_power9_intrinsics()
endif()
- if(HAVE_VMX OR HAVE_POWER8_INTRIN OR HAVE_POWER9_INTRIN)
+ if(POWER8_NEED_AUXVEC_H OR POWER9_NEED_AUXVEC_H)
+ add_definitions(-DPOWER_NEED_AUXVEC_H)
+ endif()
+ if(HAVE_POWER8_INTRIN OR HAVE_POWER9_INTRIN)
add_definitions(-DPOWER_FEATURES)
+ endif()
+ if(HAVE_VMX OR HAVE_POWER8_INTRIN OR HAVE_POWER9_INTRIN)
list(APPEND ZLIB_ARCH_HDRS ${ARCHDIR}/power_features.h)
list(APPEND ZLIB_ARCH_SRCS ${ARCHDIR}/power_features.c)
endif()
/* power_features.c - POWER feature check
* Copyright (C) 2020 Matheus Castanho <msc@linux.ibm.com>, IBM
- * Copyright (C) 2021-2022 Mika T. Lindqvist <postmaster@raasu.org>
+ * Copyright (C) 2021-2024 Mika T. Lindqvist <postmaster@raasu.org>
* For conditions of distribution and use, see copyright notice in zlib.h
*/
#ifdef HAVE_SYS_AUXV_H
# include <sys/auxv.h>
#endif
+#ifdef POWER_NEED_AUXVEC_H
+# include <linux/auxvec.h>
+#endif
#ifdef __FreeBSD__
# include <machine/cpu.h>
#endif
}"
HAVE_POWER8_INTRIN
)
+ if(NOT HAVE_POWER8_INTRIN AND HAVE_LINUX_AUXVEC_H)
+ check_c_source_compiles(
+ "#include <sys/auxv.h>
+ #include <linux/auxvec.h>
+ int main() {
+ return (getauxval(AT_HWCAP2) & PPC_FEATURE2_ARCH_2_07);
+ }"
+ HAVE_POWER8_INTRIN2
+ )
+ if(HAVE_POWER8_INTRIN2)
+ set(POWER8_NEED_AUXVEC_H 1)
+ set(HAVE_POWER8_INTRIN ${HAVE_POWER8_INTRIN2} CACHE INTERNAL "Have POWER8 intrinsics" FORCE)
+ unset(HAVE_POWER8_INTRIN2 CACHE)
+ endif()
+ endif()
set(CMAKE_REQUIRED_FLAGS)
endmacro()
}"
HAVE_POWER9_INTRIN
)
+ if(NOT HAVE_POWER9_INTRIN AND HAVE_LINUX_AUXVEC_H)
+ check_c_source_compiles(
+ "#include <sys/auxv.h>
+ #include <linux/auxvec.h>
+ int main() {
+ return (getauxval(AT_HWCAP2) & PPC_FEATURE2_ARCH_3_00);
+ }"
+ HAVE_POWER9_INTRIN2
+ )
+ if(HAVE_POWER9_INTRIN2)
+ set(POWER9_NEED_AUXVEC_H 1)
+ set(HAVE_POWER9_INTRIN ${HAVE_POWER9_INTRIN2} CACHE INTERNAL "Have POWER9 intrinsics" FORCE)
+ unset(HAVE_POWER9_INTRIN2 CACHE)
+ endif()
+ endif()
set(CMAKE_REQUIRED_FLAGS)
endmacro()