From a2e5a34df66637db1eb08ace550210a7d5b230d2 Mon Sep 17 00:00:00 2001 From: Maciej Bocianski Date: Mon, 20 Jan 2020 13:24:41 +0100 Subject: [PATCH] unittests: fix windows build - set equeue platform to posix for MINGW - enable PRIx formatting globally - remove redundant Semaphore implementation --- UNITTESTS/CMakeLists.txt | 7 +++++++ UNITTESTS/target_h/rtos/Semaphore.h | 14 +++++++------- events/internal/equeue_platform.h | 2 +- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/UNITTESTS/CMakeLists.txt b/UNITTESTS/CMakeLists.txt index 18dc8af047..1ef06cff65 100644 --- a/UNITTESTS/CMakeLists.txt +++ b/UNITTESTS/CMakeLists.txt @@ -19,6 +19,13 @@ endmacro() use_cxx14() + +if (MINGW) + # enable PRIx formatting globally + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__STDC_FORMAT_MACROS") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__STDC_FORMAT_MACROS") +endif (MINGW) + #################### # GTEST #################### diff --git a/UNITTESTS/target_h/rtos/Semaphore.h b/UNITTESTS/target_h/rtos/Semaphore.h index e0051f2b0e..ded7fe6394 100644 --- a/UNITTESTS/target_h/rtos/Semaphore.h +++ b/UNITTESTS/target_h/rtos/Semaphore.h @@ -23,13 +23,13 @@ namespace rtos { class Semaphore { public: - Semaphore(int32_t count = 0) {}; - Semaphore(int32_t count, uint16_t max_count) {}; - void acquire() {}; - bool try_acquire() { return false; }; - bool try_acquire_for(uint32_t millisec) { return false; }; - bool try_acquire_until(uint64_t millisec) { return false; }; - osStatus release(void) {return 0;}; + Semaphore(int32_t count = 0); + Semaphore(int32_t count, uint16_t max_count); + void acquire(); + bool try_acquire(); + bool try_acquire_for(uint32_t millisec); + bool try_acquire_until(uint64_t millisec); + osStatus release(void); }; } diff --git a/events/internal/equeue_platform.h b/events/internal/equeue_platform.h index 6184957b20..5d47c148d4 100644 --- a/events/internal/equeue_platform.h +++ b/events/internal/equeue_platform.h @@ -35,7 +35,7 @@ extern "C" { // Try to infer a platform if none was manually selected #if !defined(EQUEUE_PLATFORM_POSIX) \ && !defined(EQUEUE_PLATFORM_MBED) -#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) +#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) || defined(__MINGW32__) || defined(__MINGW64__) #define EQUEUE_PLATFORM_POSIX #elif defined(__MBED__) #define EQUEUE_PLATFORM_MBED