diff --git a/CMakeLists.txt b/CMakeLists.txt index 74beaee5f1..22281de9c3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -755,6 +755,9 @@ if(UNIX OR MINGW) # TODO: # - std::aligned_alloc() C++17 / C11 endif() + + CHECK_SYMBOL_EXISTS(getauxval sys/auxv.h HAVE_GETAUXVAL) + CHECK_SYMBOL_EXISTS(elf_aux_info sys/auxv.h HAVE_ELF_AUX_INFO) elseif(WIN32) include(CheckIncludeFile) include(CheckSymbolExists) diff --git a/modules/core/CMakeLists.txt b/modules/core/CMakeLists.txt index 95fe8d6a4c..2412168c9d 100644 --- a/modules/core/CMakeLists.txt +++ b/modules/core/CMakeLists.txt @@ -115,6 +115,12 @@ endif() if(HAVE_WIN32_ALIGNED_MALLOC) ocv_append_source_file_compile_definitions(${CMAKE_CURRENT_SOURCE_DIR}/src/alloc.cpp "HAVE_WIN32_ALIGNED_MALLOC=1") endif() +if(HAVE_GETAUXVAL) + ocv_append_source_file_compile_definitions(${CMAKE_CURRENT_SOURCE_DIR}/src/system.cpp "HAVE_GETAUXVAL=1") +endif() +if(HAVE_ELF_AUX_INFO) + ocv_append_source_file_compile_definitions(${CMAKE_CURRENT_SOURCE_DIR}/src/system.cpp "HAVE_ELF_AUX_INFO=1") +endif() if(HAVE_VA_INTEL_OLD_HEADER) ocv_append_source_file_compile_definitions("${CMAKE_CURRENT_LIST_DIR}/src/va_intel.cpp" "HAVE_VA_INTEL_OLD_HEADER") endif() diff --git a/modules/core/src/system.cpp b/modules/core/src/system.cpp index 810f62297a..98f26d5118 100644 --- a/modules/core/src/system.cpp +++ b/modules/core/src/system.cpp @@ -151,7 +151,7 @@ const uint64_t AT_HWCAP = NT_GNU_HWCAP; #endif -#if (defined __ppc64__ || defined __PPC64__) && defined __unix__ +#if ((defined __ppc64__ || defined __PPC64__) && (defined HAVE_GETAUXVAL || defined HAVE_ELF_AUX_INFO)) # include "sys/auxv.h" # ifndef AT_HWCAP2 # define AT_HWCAP2 26 @@ -686,7 +686,7 @@ struct HWFeatures have[CV_CPU_MSA] = true; #endif - #if (defined __ppc64__ || defined __PPC64__) && defined __linux__ + #if (defined __ppc64__ || defined __PPC64__) && defined HAVE_GETAUXVAL unsigned int hwcap = getauxval(AT_HWCAP); if (hwcap & PPC_FEATURE_HAS_VSX) { hwcap = getauxval(AT_HWCAP2); @@ -696,7 +696,7 @@ struct HWFeatures have[CV_CPU_VSX] = (hwcap & PPC_FEATURE2_ARCH_2_07) != 0; } } - #elif (defined __ppc64__ || defined __PPC64__) && defined __FreeBSD__ + #elif (defined __ppc64__ || defined __PPC64__) && defined HAVE_ELF_AUX_INFO unsigned long hwcap = 0; elf_aux_info(AT_HWCAP, &hwcap, sizeof(hwcap)); if (hwcap & PPC_FEATURE_HAS_VSX) { @@ -708,7 +708,7 @@ struct HWFeatures } } #else - // TODO: AIX, OpenBSD + // TODO: AIX #if CV_VSX || defined _ARCH_PWR8 || defined __POWER9_VECTOR__ have[CV_CPU_VSX] = true; #endif