forked from microsoft/winrtc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path3008-Fixing-UWP-build-for-time_utils.cc
46 lines (39 loc) · 1.5 KB
/
3008-Fixing-UWP-build-for-time_utils.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
From 6d9f314982b0b0f95692952d6744c6eb9f325bde Mon Sep 17 00:00:00 2001
From: Augusto Righetto <[email protected]>
Date: Mon, 23 Dec 2019 11:27:37 -0800
Subject: [PATCH] Fixing timing issues for the UWP build
1. safe_conversions.h is being included directly on Mac builds, but not on Windows builds.
Probably safe_conversions.h is indirectly included on Windows builds by some header that is not being built on UWP builds.
2. Converting to nano seconds in way that fits the variable precision.
---
rtc_base/time_utils.cc | 5 +++++
system_wrappers/source/clock.cc | 2 +-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/rtc_base/time_utils.cc b/rtc_base/time_utils.cc
index 7a72173db7..4033c12740 100644
--- a/rtc_base/time_utils.cc
+++ b/rtc_base/time_utils.cc
@@ -26,6 +26,11 @@
#include <windows.h>
#include <mmsystem.h>
#include <sys/timeb.h>
+
+#if defined(WINUWP)
+#include "rtc_base/numerics/safe_conversions.h"
+#endif
+
// clang-format on
#endif
diff --git a/system_wrappers/source/clock.cc b/system_wrappers/source/clock.cc
index 3eea155711..5976fb2562 100644
--- a/system_wrappers/source/clock.cc
+++ b/system_wrappers/source/clock.cc
@@ -97,7 +97,7 @@ class WinUwpRealTimeClock final : public RealTimeClock {
struct timeval tv;
tv.tv_sec = rtc::dchecked_cast<long>(nanos / 1000000000);
- tv.tv_usec = rtc::dchecked_cast<long>(nanos / 1000);
+ tv.tv_usec = rtc::dchecked_cast<long>((nanos % 1000000000) / 1000);
return tv;
}
--
2.22.0.vfs.1.1.57.gbaf16c8