Skip to content

Commit b46e741

Browse files
committed
core(alloc): drop unused code, use memalign() functions instead of hacks
valgrind provides better detection without memory buffer hacks
1 parent 34f9c03 commit b46e741

File tree

5 files changed

+42
-627
lines changed

5 files changed

+42
-627
lines changed

CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,7 @@ if(UNIX)
551551
endif()
552552
include(CheckFunctionExists)
553553
include(CheckIncludeFile)
554+
include(CheckSymbolExists)
554555

555556
if(NOT APPLE)
556557
CHECK_INCLUDE_FILE(pthread.h HAVE_LIBPTHREAD)
@@ -566,6 +567,12 @@ if(UNIX)
566567
else()
567568
set(HAVE_LIBPTHREAD YES)
568569
endif()
570+
571+
CHECK_SYMBOL_EXISTS(posix_memalign stdlib.h HAVE_POSIX_MEMALIGN)
572+
CHECK_INCLUDE_FILE(malloc.h HAVE_MALLOC_H)
573+
if(HAVE_MALLOC_H)
574+
CHECK_SYMBOL_EXISTS(memalign malloc.h HAVE_MEMALIGN)
575+
endif()
569576
endif()
570577

571578
include(cmake/OpenCVPCHSupport.cmake)

modules/core/CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,16 @@ endif()
4545
if(ITT_INCLUDE_DIRS)
4646
ocv_module_include_directories(${ITT_INCLUDE_DIRS})
4747
endif()
48+
if(HAVE_POSIX_MEMALIGN)
49+
ocv_append_sourge_file_compile_definitions(${CMAKE_CURRENT_SOURCE_DIR}/src/alloc.cpp "HAVE_POSIX_MEMALIGN=1")
50+
endif()
51+
if(HAVE_MALLOC_H)
52+
ocv_append_sourge_file_compile_definitions(${CMAKE_CURRENT_SOURCE_DIR}/src/alloc.cpp "HAVE_MALLOC_H=1")
53+
endif()
54+
if(HAVE_MEMALIGN)
55+
ocv_append_sourge_file_compile_definitions(${CMAKE_CURRENT_SOURCE_DIR}/src/alloc.cpp "HAVE_MEMALIGN=1")
56+
endif()
57+
4858
ocv_create_module(${extra_libs})
4959

5060
ocv_target_link_libraries(${the_module}

0 commit comments

Comments
 (0)