From d0960a1149e3f591ae804308ecc544b481191cda Mon Sep 17 00:00:00 2001 From: Alexey Ozeritskiy Date: Sun, 10 Nov 2024 18:17:44 +0000 Subject: [PATCH] Win32 preparations (#43) --- coroio/base.hpp | 5 ++++- coroio/poll.hpp | 5 +++++ coroio/poller.hpp | 9 ++++++++- coroio/select.hpp | 4 ++++ coroio/socket.hpp | 5 +++++ 5 files changed, 26 insertions(+), 2 deletions(-) diff --git a/coroio/base.hpp b/coroio/base.hpp index ab4df03..6125902 100644 --- a/coroio/base.hpp +++ b/coroio/base.hpp @@ -67,7 +67,10 @@ GetDurationPair(TTime now, TTime deadline, std::chrono::milliseconds maxDuration inline timespec GetTimespec(TTime now, TTime deadline, std::chrono::milliseconds maxDuration) { auto [p1, p2] = GetDurationPair(now, deadline, maxDuration); - return {p1.count(), p2.count()}; + timespec ret; + ret.tv_sec = p1.count(); + ret.tv_nsec = p2.count(); + return ret; } } // namespace NNet diff --git a/coroio/poll.hpp b/coroio/poll.hpp index 6d3ec88..291f715 100644 --- a/coroio/poll.hpp +++ b/coroio/poll.hpp @@ -1,6 +1,11 @@ #pragma once +#ifdef _WIN32 +#include +#else #include +#endif + #include #include diff --git a/coroio/poller.hpp b/coroio/poller.hpp index 5965767..c4686bb 100644 --- a/coroio/poller.hpp +++ b/coroio/poller.hpp @@ -9,6 +9,10 @@ #include "base.hpp" +#ifdef Yield +#undef Yield +#endif + namespace NNet { class TPollerBase { @@ -142,7 +146,10 @@ class TPollerBase { static constexpr timespec GetMaxDuration(std::chrono::milliseconds duration) { auto p1 = std::chrono::duration_cast(duration); auto p2 = std::chrono::duration_cast(duration - p1); - return {p1.count(), p2.count()}; + timespec ts; + ts.tv_sec = p1.count(); + ts.tv_nsec = p2.count(); + return ts; } void Reset() { diff --git a/coroio/select.hpp b/coroio/select.hpp index d9f1cbd..f674358 100644 --- a/coroio/select.hpp +++ b/coroio/select.hpp @@ -1,6 +1,10 @@ #pragma once +#ifdef _WIN32 +#include +#else #include +#endif #include #include diff --git a/coroio/socket.hpp b/coroio/socket.hpp index 26627e8..1e0c466 100644 --- a/coroio/socket.hpp +++ b/coroio/socket.hpp @@ -1,5 +1,9 @@ #pragma once +#ifdef _WIN32 +#include +#include +#else #include #include #include @@ -7,6 +11,7 @@ #include #include #include +#endif #include