Skip to content

Commit

Permalink
Merge pull request opencv#26798 from brad0:opencv_powerpc_elf_aux_info
Browse files Browse the repository at this point in the history
Add CMake checks for getauxval and elf_aux_info for POWER
  • Loading branch information
asmorkalov authored Jan 20, 2025
2 parents 2db6b29 + 918196e commit 6f24d75
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions modules/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
8 changes: 4 additions & 4 deletions modules/core/src/system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand All @@ -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) {
Expand All @@ -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
Expand Down

0 comments on commit 6f24d75

Please sign in to comment.