aboutsummaryrefslogtreecommitdiff
path: root/utils/telldus-core
diff options
context:
space:
mode:
authorRosen Penev <rosenp@gmail.com>2019-10-04 13:23:33 -0700
committerRosen Penev <rosenp@gmail.com>2019-10-04 13:23:33 -0700
commit2cff5b6563e4b8d70c5e9aaaa38fe6052cd2908b (patch)
treef91de3d4d4a681824b0db2e155944fedfd27e8bf /utils/telldus-core
parent8a977c8b6ec0d25b6fd07b232f6f182a817c1cfe (diff)
telldus-core: Fix compilation without usleep
Uses C++11's sleep_for, which internally uses nanosleep. Signed-off-by: Rosen Penev <rosenp@gmail.com>
Diffstat (limited to 'utils/telldus-core')
-rw-r--r--utils/telldus-core/patches/930-usleep.patch40
1 files changed, 40 insertions, 0 deletions
diff --git a/utils/telldus-core/patches/930-usleep.patch b/utils/telldus-core/patches/930-usleep.patch
new file mode 100644
index 000000000..7c30a105e
--- /dev/null
+++ b/utils/telldus-core/patches/930-usleep.patch
@@ -0,0 +1,40 @@
+--- a/common/common.h
++++ b/common/common.h
+@@ -25,15 +25,13 @@
+ #ifdef _WINDOWS
+ #include <fstream> // NOLINT(readability/streams)
+ #endif
++#include <chrono>
+ #include <string>
++#include <thread>
+ #include "common/Strings.h"
+
+ inline void msleep( const int msec) {
+-#ifdef _WINDOWS
+- Sleep(msec);
+-#else
+- usleep(msec*1000);
+-#endif
++ std::this_thread::sleep_for(std::chrono::milliseconds(msec));
+ }
+
+ inline void dlog(const char *fmt, ...) {
+--- a/service/TellStick_libftdi.cpp
++++ b/service/TellStick_libftdi.cpp
+@@ -8,7 +8,6 @@
+ #include <string.h>
+ #include <stdlib.h>
+ #include <stdio.h>
+-#include <unistd.h>
+ #include <list>
+ #include <string>
+
+@@ -231,7 +230,7 @@ int TellStick::send( const std::string &strMessage ) {
+ return TELLSTICK_SUCCESS;
+ }
+ } else if(ret == 0) { // No data available
+- usleep(100);
++ std::this_thread::sleep_for(std::chrono::microseconds(100));
+ } else { // Error
+ Log::debug("Broken pipe on read");
+ return TELLSTICK_ERROR_BROKEN_PIPE;