From 19237c3c521ed534d835e856c1c084b14bbe2c97 Mon Sep 17 00:00:00 2001 From: Niraj Desai Date: Tue, 15 Jan 2019 07:35:11 -0800 Subject: [PATCH] Support build with QNX 7.0 toolchain Steps to build: 1. Source qnx700-env.sh 2. Use QNXToolchain.cmake to build: cmake -DCMAKE_TOOLCHAIN_FILE=/path/to/QNXToolchain.cmake ../ --- easy_profiler_core/CMakeLists.txt | 5 ++++- easy_profiler_core/current_thread.h | 7 +++++++ easy_profiler_core/easy_socket.cpp | 3 +++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/easy_profiler_core/CMakeLists.txt b/easy_profiler_core/CMakeLists.txt index b4d5c7f..ae5e4d5 100644 --- a/easy_profiler_core/CMakeLists.txt +++ b/easy_profiler_core/CMakeLists.txt @@ -220,9 +220,12 @@ easy_define_target_option(easy_profiler EASY_OPTION_PREDEFINED_COLORS EASY_OPTIO # Add platform specific compile options: if (UNIX) target_compile_options(easy_profiler PRIVATE -Wall -Wno-long-long -Wno-reorder -Wno-braced-scalar-init -pedantic) - if (NOT ANDROID) + if (NOT ANDROID AND NOT QNX) target_link_libraries(easy_profiler pthread) endif() + if (QNX) + target_link_libraries(easy_profiler socket) + endif() elseif (WIN32) target_compile_definitions(easy_profiler PRIVATE -D_WIN32_WINNT=0x0600 -D_CRT_SECURE_NO_WARNINGS -D_WINSOCK_DEPRECATED_NO_WARNINGS) target_link_libraries(easy_profiler ws2_32 psapi) diff --git a/easy_profiler_core/current_thread.h b/easy_profiler_core/current_thread.h index b9ffe73..aecd810 100644 --- a/easy_profiler_core/current_thread.h +++ b/easy_profiler_core/current_thread.h @@ -50,6 +50,10 @@ The Apache License, Version 2.0 (the "License"); #elif defined(__APPLE__) # include # include +#elif defined(__QNX__) +# include +# include +# define __NR_gettid SYS_gettid #else # include # include @@ -70,6 +74,9 @@ inline profiler::thread_id_t getCurrentThreadId() # else return (profiler::thread_id_t)pthread_self(); # endif +#elif defined(__QNX__) + EASY_THREAD_LOCAL static const profiler::thread_id_t _id = (profiler::thread_id_t)gettid(); + return _id; #else EASY_THREAD_LOCAL static const profiler::thread_id_t _id = (profiler::thread_id_t)syscall(__NR_gettid); return _id; diff --git a/easy_profiler_core/easy_socket.cpp b/easy_profiler_core/easy_socket.cpp index 826e7d8..bfb1e5c 100644 --- a/easy_profiler_core/easy_socket.cpp +++ b/easy_profiler_core/easy_socket.cpp @@ -43,6 +43,9 @@ limitations under the License. #include #include #include +#if defined(__QNX__) +# include +#endif #if defined(_WIN32) # pragma comment (lib, "Ws2_32.lib")