From 83853925e08a96f3e5449cc59aa4847eefa61a90 Mon Sep 17 00:00:00 2001 From: Pablo Garrido Date: Wed, 12 Feb 2020 09:32:25 +0100 Subject: [PATCH 1/4] Relax POSIX timers error --- src/time_unix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/time_unix.c b/src/time_unix.c index 028fb453..ea52711d 100644 --- a/src/time_unix.c +++ b/src/time_unix.c @@ -39,7 +39,7 @@ extern "C" // This id an appropriate check for clock_gettime() according to: // http://man7.org/linux/man-pages/man2/clock_gettime.2.html # if !defined(_POSIX_TIMERS) || !_POSIX_TIMERS -# error no monotonic clock function available +# warning no monotonic clock function available # endif // !defined(_POSIX_TIMERS) || !_POSIX_TIMERS #endif // !defined(__MACH__) From b7bf2ff6c7a9dd7ff504f92e0af614deddfec99a Mon Sep 17 00:00:00 2001 From: Pablo Garrido Date: Wed, 12 Feb 2020 09:32:46 +0100 Subject: [PATCH 2/4] Do not use Thread_local storage --- include/rcutils/macros.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/rcutils/macros.h b/include/rcutils/macros.h index e254df46..f9bc47a7 100644 --- a/include/rcutils/macros.h +++ b/include/rcutils/macros.h @@ -57,7 +57,7 @@ extern "C" #endif #else // Some other non-Windows, non-cygwin, non-apple OS - #define RCUTILS_THREAD_LOCAL _Thread_local + #define RCUTILS_THREAD_LOCAL #endif #define RCUTILS_STRINGIFY_IMPL(x) #x From 7588a0670c2a6c61bfd970b4f55a05e1d270366c Mon Sep 17 00:00:00 2001 From: Pablo Garrido Date: Fri, 6 Mar 2020 12:57:00 +0100 Subject: [PATCH 3/4] Added flag for Thread compatibility --- CMakeLists.txt | 10 +++------- include/rcutils/macros.h | 6 ++++-- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8240c803..67ec94e6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,13 +29,9 @@ else() set(time_impl_c src/time_unix.c) endif() -if(RCUTILS_NO_FILESYSTEM) - add_compile_options(-DRCUTILS_NO_FILESYSTEM=1) -endif() - -if(RCUTILS_AVOID_DYNAMIC_ALLOCATION) - add_compile_options(-DRCUTILS_AVOID_DYNAMIC_ALLOCATION=1) -endif() +target_compile_definitions(${PROJECT_NAME} PRIVATE "RCUTILS_NO_FILESYSTEM") +target_compile_definitions(${PROJECT_NAME} PRIVATE "RCUTILS_NO_THREAD_SUPPORT") +target_compile_definitions(${PROJECT_NAME} PRIVATE "RCUTILS_AVOID_DYNAMIC_ALLOCATION") configure_file ( "${PROJECT_SOURCE_DIR}/include/rcutils/error_handling.h.in" diff --git a/include/rcutils/macros.h b/include/rcutils/macros.h index f9bc47a7..11981683 100644 --- a/include/rcutils/macros.h +++ b/include/rcutils/macros.h @@ -28,7 +28,9 @@ extern "C" // Note: this block was migrated from rmw/macros.h // This block either sets RCUTILS_THREAD_LOCAL or RCUTILS_THREAD_LOCAL_PTHREAD. -#if defined _WIN32 || defined __CYGWIN__ +#if RCUTILS_NO_THREAD_SUPPORT + #define RCUTILS_THREAD_LOCAL +#elif defined _WIN32 || defined __CYGWIN__ // Windows or Cygwin #define RCUTILS_THREAD_LOCAL __declspec(thread) #elif defined __APPLE__ @@ -57,7 +59,7 @@ extern "C" #endif #else // Some other non-Windows, non-cygwin, non-apple OS - #define RCUTILS_THREAD_LOCAL + #define RCUTILS_THREAD_LOCAL _Thread_local #endif #define RCUTILS_STRINGIFY_IMPL(x) #x From bfcb7dd4da4208e3bfab047f1811a93db1dfbf4c Mon Sep 17 00:00:00 2001 From: Pablo Garrido Date: Mon, 9 Mar 2020 10:14:56 +0100 Subject: [PATCH 4/4] Fix to make it work --- CMakeLists.txt | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 67ec94e6..1af7100e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,9 +29,21 @@ else() set(time_impl_c src/time_unix.c) endif() -target_compile_definitions(${PROJECT_NAME} PRIVATE "RCUTILS_NO_FILESYSTEM") -target_compile_definitions(${PROJECT_NAME} PRIVATE "RCUTILS_NO_THREAD_SUPPORT") -target_compile_definitions(${PROJECT_NAME} PRIVATE "RCUTILS_AVOID_DYNAMIC_ALLOCATION") +if(RCUTILS_NO_FILESYSTEM) + add_compile_options(-DRCUTILS_NO_FILESYSTEM=1) +endif() + +if(RCUTILS_NO_THREAD_SUPPORT) + add_compile_options(-DRCUTILS_NO_THREAD_SUPPORT=1) +endif() + +if(RCUTILS_AVOID_DYNAMIC_ALLOCATION) + add_compile_options(-DRCUTILS_AVOID_DYNAMIC_ALLOCATION=1) +endif() + +# target_compile_definitions(${PROJECT_NAME} PRIVATE "RCUTILS_NO_FILESYSTEM") +# target_compile_definitions(${PROJECT_NAME} PRIVATE "RCUTILS_NO_THREAD_SUPPORT") +# target_compile_definitions(${PROJECT_NAME} PRIVATE "RCUTILS_AVOID_DYNAMIC_ALLOCATION") configure_file ( "${PROJECT_SOURCE_DIR}/include/rcutils/error_handling.h.in"