Merge pull request 'Windows Tweaks' (#691) from eive/fsfw:windows-tweaks-upstream into development
Reviewed-on: fsfw/fsfw#691
This commit is contained in:
commit
d7e16a67a7
@ -140,7 +140,7 @@ find_program( GCOV_PATH gcov )
|
||||
find_program( LCOV_PATH NAMES lcov lcov.bat lcov.exe lcov.perl)
|
||||
find_program( FASTCOV_PATH NAMES fastcov fastcov.py )
|
||||
find_program( GENHTML_PATH NAMES genhtml genhtml.perl genhtml.bat )
|
||||
find_program( GCOVR_PATH gcovr PATHS ${CMAKE_SOURCE_DIR}/scripts/test)
|
||||
find_program( GCOVR_PATH gcovr )
|
||||
find_program( CPPFILT_PATH NAMES c++filt )
|
||||
|
||||
if(NOT GCOV_PATH)
|
||||
|
@ -1,8 +1,8 @@
|
||||
#include "fsfw/globalfunctions/timevalOperations.h"
|
||||
|
||||
timeval& operator+=(timeval& lhs, const timeval& rhs) {
|
||||
int64_t sum = lhs.tv_sec * 1000000. + lhs.tv_usec;
|
||||
sum += rhs.tv_sec * 1000000. + rhs.tv_usec;
|
||||
int64_t sum = static_cast<int64_t>(lhs.tv_sec) * 1000000. + lhs.tv_usec;
|
||||
sum += static_cast<int64_t>(rhs.tv_sec) * 1000000. + rhs.tv_usec;
|
||||
lhs.tv_sec = sum / 1000000;
|
||||
lhs.tv_usec = sum - lhs.tv_sec * 1000000;
|
||||
return lhs;
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include "fsfw/osal/common/TcpIpBase.h"
|
||||
|
||||
#include "fsfw/platform.h"
|
||||
#include "fsfw/serviceinterface.h"
|
||||
|
||||
#ifdef PLATFORM_UNIX
|
||||
#include <errno.h>
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
#if defined(PLATFORM_WIN)
|
||||
#include <sysinfoapi.h>
|
||||
#define timegm _mkgmtime
|
||||
#elif defined(PLATFORM_UNIX)
|
||||
#include <fstream>
|
||||
#endif
|
||||
|
@ -1,5 +1,7 @@
|
||||
#include "fsfw/osal/windows/winTaskHelpers.h"
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include <mutex>
|
||||
|
||||
TaskPriority tasks::makeWinPriority(PriorityClass prioClass, PriorityNumber prioNumber) {
|
||||
|
@ -1,10 +1,12 @@
|
||||
#include <map>
|
||||
#include <thread>
|
||||
|
||||
#include "../../tasks/TaskFactory.h"
|
||||
#include "fsfw/tasks/TaskFactory.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
#include <minwindef.h>
|
||||
|
||||
namespace tasks {
|
||||
|
||||
enum PriorityClass : uint16_t {
|
||||
|
@ -3,7 +3,6 @@
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
|
||||
#include <cinttypes>
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "fsfw/serviceinterface/serviceInterfaceDefintions.h"
|
||||
|
@ -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;
|
||||
|
@ -4,6 +4,13 @@
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "fsfw/platform.h"
|
||||
|
||||
#ifdef PLATFORM_WIN
|
||||
// wtf? Required for timeval!
|
||||
#include <winsock.h>
|
||||
#endif
|
||||
|
||||
#include "TimeStampIF.h"
|
||||
#include "fsfw/returnvalues/returnvalue.h"
|
||||
#include "fsfw/serialize/SerializeIF.h"
|
||||
|
@ -5,6 +5,14 @@
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
#ifdef PLATFORM_WIN
|
||||
// Defined in Windows header for whatever reason, and leads to nameclash issues with
|
||||
// class enums which have entries of the same name.
|
||||
#undef IN
|
||||
#undef OUT
|
||||
#undef CALLBACK
|
||||
#endif
|
||||
|
||||
using gpioId_t = uint16_t;
|
||||
|
||||
namespace gpio {
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
|
||||
void __attribute__((weak)) printChar(const char* character, bool errStream) {
|
||||
if (errStream) {
|
||||
|
@ -56,6 +56,7 @@ TEST_CASE("TimevalTest", "[timevalOperations]") {
|
||||
}
|
||||
SECTION("Operators") {
|
||||
timeval t1;
|
||||
if (sizeof(t1.tv_sec) == 8) {
|
||||
t1.tv_sec = 1648227422;
|
||||
t1.tv_usec = 123456;
|
||||
timeval t2;
|
||||
@ -76,7 +77,9 @@ TEST_CASE("TimevalTest", "[timevalOperations]") {
|
||||
t6.tv_usec = 999999;
|
||||
|
||||
timeval t7 = t6 + t1;
|
||||
// Overflow test
|
||||
REQUIRE(t7.tv_sec == (1648227422ull + 1648227400ull + 1ull));
|
||||
|
||||
REQUIRE(t7.tv_usec == 123455);
|
||||
|
||||
timeval t8 = t1 - t6;
|
||||
@ -112,6 +115,7 @@ TEST_CASE("TimevalTest", "[timevalOperations]") {
|
||||
double scalar5 = t12 / t1;
|
||||
REQUIRE(scalar5 == Catch::Approx(0.5));
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("timevalOperations::toTimeval") {
|
||||
double seconds = 1648227422.123456;
|
||||
|
@ -1,3 +1,5 @@
|
||||
target_sources(${FSFW_TEST_TGT} PRIVATE
|
||||
if(UNIX)
|
||||
target_sources(${FSFW_TEST_TGT} PRIVATE
|
||||
testCommandExecutor.cpp
|
||||
)
|
||||
)
|
||||
endif()
|
||||
|
Loading…
Reference in New Issue
Block a user