Skip to content

Commit 2c634ee

Browse files
committed
Merge pull request opencv#19023 from alalek:core_update_allocator_stats_type
2 parents c6e60f0 + 26e8048 commit 2c634ee

File tree

2 files changed

+25
-9
lines changed

2 files changed

+25
-9
lines changed

modules/core/CMakeLists.txt

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,24 @@ option(OPENCV_ENABLE_ALLOCATOR_STATS "Enable Allocator metrics" ON)
8282

8383
if(NOT OPENCV_ENABLE_ALLOCATOR_STATS)
8484
add_definitions(-DOPENCV_DISABLE_ALLOCATOR_STATS=1)
85-
else()
85+
elseif(HAVE_CXX11 OR DEFINED OPENCV_ALLOCATOR_STATS_COUNTER_TYPE)
8686
if(NOT DEFINED OPENCV_ALLOCATOR_STATS_COUNTER_TYPE)
8787
if(HAVE_ATOMIC_LONG_LONG AND OPENCV_ENABLE_ATOMIC_LONG_LONG)
88-
set(OPENCV_ALLOCATOR_STATS_COUNTER_TYPE "long long")
88+
if(MINGW)
89+
# command-line generation issue due to space in value, int/int64_t should be used instead
90+
# https://github.com/opencv/opencv/issues/16990
91+
message(STATUS "Consider adding OPENCV_ALLOCATOR_STATS_COUNTER_TYPE=int/int64_t according to your build configuration")
92+
else()
93+
set(OPENCV_ALLOCATOR_STATS_COUNTER_TYPE "long long")
94+
endif()
8995
else()
9096
set(OPENCV_ALLOCATOR_STATS_COUNTER_TYPE "int")
9197
endif()
9298
endif()
93-
message(STATUS "Allocator metrics storage type: '${OPENCV_ALLOCATOR_STATS_COUNTER_TYPE}'")
94-
add_definitions("-DOPENCV_ALLOCATOR_STATS_COUNTER_TYPE=${OPENCV_ALLOCATOR_STATS_COUNTER_TYPE}")
99+
if(DEFINED OPENCV_ALLOCATOR_STATS_COUNTER_TYPE)
100+
message(STATUS "Allocator metrics storage type: '${OPENCV_ALLOCATOR_STATS_COUNTER_TYPE}'")
101+
add_definitions("-DOPENCV_ALLOCATOR_STATS_COUNTER_TYPE=${OPENCV_ALLOCATOR_STATS_COUNTER_TYPE}")
102+
endif()
95103
endif()
96104

97105

modules/core/include/opencv2/core/utils/allocator_stats.impl.hpp

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,11 @@
77

88
#include "./allocator_stats.hpp"
99

10-
#ifdef CV_CXX11
11-
#include <atomic>
12-
#endif
13-
1410
//#define OPENCV_DISABLE_ALLOCATOR_STATS
1511

16-
namespace cv { namespace utils {
12+
#ifdef CV_CXX11
13+
14+
#include <atomic>
1715

1816
#ifndef OPENCV_ALLOCATOR_STATS_COUNTER_TYPE
1917
#if defined(__GNUC__) && (\
@@ -28,6 +26,16 @@ namespace cv { namespace utils {
2826
#define OPENCV_ALLOCATOR_STATS_COUNTER_TYPE long long
2927
#endif
3028

29+
#else // CV_CXX11
30+
31+
#ifndef OPENCV_ALLOCATOR_STATS_COUNTER_TYPE
32+
#define OPENCV_ALLOCATOR_STATS_COUNTER_TYPE int // CV_XADD supports int only
33+
#endif
34+
35+
#endif // CV_CXX11
36+
37+
namespace cv { namespace utils {
38+
3139
#ifdef CV__ALLOCATOR_STATS_LOG
3240
namespace {
3341
#endif

0 commit comments

Comments
 (0)