#undef min
#undef max
#undef abs
+#elif defined(__linux__)
+#include <dlfcn.h> // requires -ldl
#elif defined(__APPLE__)
#include <TargetConditionals.h>
#if TARGET_OS_MAC
}
}
#elif defined(__linux__)
- std::ifstream fs("/proc/self/maps");
- std::string line;
- while (std::getline(fs, line, '\n'))
+ Dl_info info;
+ if (0 != dladdr(addr, &info))
{
- long long int addr_begin = 0, addr_end = 0;
- if (2 == sscanf(line.c_str(), "%llx-%llx", &addr_begin, &addr_end))
- {
- if ((intptr_t)addr >= (intptr_t)addr_begin && (intptr_t)addr < (intptr_t)addr_end)
- {
- size_t pos = line.rfind(" "); // 2 spaces
- if (pos == cv::String::npos)
- pos = line.rfind(' '); // 1 spaces
- else
- pos++;
- if (pos == cv::String::npos)
- {
- CV_LOG_DEBUG(NULL, "Can't parse module path: '" << line << '\'');
- }
- return line.substr(pos + 1);
- }
- }
+ return cv::String(info.dli_fname);
}
#elif defined(__APPLE__)
# if TARGET_OS_MAC