From 6d2f44a432aaf36ab27bd47a54bb0c96479c1c81 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 27 Sep 2022 21:46:11 +0200 Subject: [PATCH] tweaks to make windows build again --- src/fsfw/osal/host/Clock.cpp | 1 + src/fsfw/osal/windows/winTaskHelpers.cpp | 1 + src/fsfw/osal/windows/winTaskHelpers.h | 4 +++- src/fsfw/timemanager/ClockCommon.cpp | 8 +++++++- src/fsfw/timemanager/TimeReaderIF.h | 6 ++++++ 5 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/fsfw/osal/host/Clock.cpp b/src/fsfw/osal/host/Clock.cpp index 29c6c1a6..dbf6529c 100644 --- a/src/fsfw/osal/host/Clock.cpp +++ b/src/fsfw/osal/host/Clock.cpp @@ -8,6 +8,7 @@ #if defined(PLATFORM_WIN) #include +#define timegm _mkgmtime #elif defined(PLATFORM_UNIX) #include #endif diff --git a/src/fsfw/osal/windows/winTaskHelpers.cpp b/src/fsfw/osal/windows/winTaskHelpers.cpp index 206ee7a7..5b4feb86 100644 --- a/src/fsfw/osal/windows/winTaskHelpers.cpp +++ b/src/fsfw/osal/windows/winTaskHelpers.cpp @@ -1,6 +1,7 @@ #include "fsfw/osal/windows/winTaskHelpers.h" #include +#include TaskPriority tasks::makeWinPriority(PriorityClass prioClass, PriorityNumber prioNumber) { return (static_cast(prioClass) << 16) | static_cast(prioNumber); diff --git a/src/fsfw/osal/windows/winTaskHelpers.h b/src/fsfw/osal/windows/winTaskHelpers.h index 87cd92ce..2d6ef9b4 100644 --- a/src/fsfw/osal/windows/winTaskHelpers.h +++ b/src/fsfw/osal/windows/winTaskHelpers.h @@ -1,10 +1,12 @@ #include #include -#include "../../tasks/TaskFactory.h" +#include "fsfw/tasks/TaskFactory.h" #ifdef _WIN32 +#include + namespace tasks { enum PriorityClass : uint16_t { diff --git a/src/fsfw/timemanager/ClockCommon.cpp b/src/fsfw/timemanager/ClockCommon.cpp index 45755f35..d0ac9004 100644 --- a/src/fsfw/timemanager/ClockCommon.cpp +++ b/src/fsfw/timemanager/ClockCommon.cpp @@ -61,10 +61,16 @@ ReturnValue_t Clock::convertTimevalToTimeOfDay(const timeval* from, TimeOfDay_t* if (result != returnvalue::OK) { return result; } - MutexGuard helper(timeMutex); // gmtime writes its output in a global buffer which is not Thread Safe // Therefore we have to use a Mutex here + MutexGuard helper(timeMutex); +#ifdef PLATFORM_WIN + time_t time; + time = from->tv_sec; + timeInfo = gmtime(&time); +#else timeInfo = gmtime(&from->tv_sec); +#endif to->year = timeInfo->tm_year + 1900; to->month = timeInfo->tm_mon + 1; to->day = timeInfo->tm_mday; diff --git a/src/fsfw/timemanager/TimeReaderIF.h b/src/fsfw/timemanager/TimeReaderIF.h index a3343e1c..ceb0a872 100644 --- a/src/fsfw/timemanager/TimeReaderIF.h +++ b/src/fsfw/timemanager/TimeReaderIF.h @@ -2,6 +2,12 @@ #define FSFW_TIMEMANAGER_TIMEREADERIF_H #include +#include "fsfw/platform.h" + +#ifdef PLATFORM_WIN +// wtf? Required for timeval! +#include +#endif #include "TimeStampIF.h" #include "fsfw/returnvalues/returnvalue.h"