[#766] add x-compile support for QNX SDP7 (#770)

Since googletest already supports x-compilation for QNX, it is nice to
 have google benchmark support it too.
Fixes #766
This commit is contained in:
Jilin Zhou 2019-02-19 08:05:55 -05:00 committed by Dominic Hamon
parent 7c571338b5
commit 0ae233ab23
3 changed files with 8 additions and 0 deletions

View File

@ -183,6 +183,10 @@ else()
add_definitions(-D_GNU_SOURCE=1)
endif()
if (QNXNTO)
add_definitions(-D_QNX_SOURCE)
endif()
# Link time optimisation
if (BENCHMARK_ENABLE_LTO)
add_cxx_compiler_flag(-flto)

View File

@ -70,6 +70,8 @@
#define BENCHMARK_OS_FUCHSIA 1
#elif defined (__SVR4) && defined (__sun)
#define BENCHMARK_OS_SOLARIS 1
#elif defined(__QNX__)
#define BENCHMARK_OS_QNX 1
#endif
#if defined(__ANDROID__) && defined(__GLIBCXX__)

View File

@ -389,6 +389,8 @@ std::string GetSystemName() {
#else // defined(BENCHMARK_OS_WINDOWS)
#ifdef BENCHMARK_OS_MACOSX //Mac Doesnt have HOST_NAME_MAX defined
#define HOST_NAME_MAX 64
#elif defined(BENCHMARK_OS_QNX)
#define HOST_NAME_MAX 154
#endif
char hostname[HOST_NAME_MAX];
int retVal = gethostname(hostname, HOST_NAME_MAX);