Browse Source

Fixes to compile on mingw32

Eduardo Bart 3 years ago
parent
commit
aa19f45d94
2 changed files with 5 additions and 17 deletions
  1. 1
    1
      src/framework/CMakeLists.txt
  2. 4
    16
      src/framework/stdext/time.cpp

+ 1
- 1
src/framework/CMakeLists.txt View File

@@ -195,7 +195,7 @@ message(STATUS "Build revision: ${BUILD_REVISION}")
195 195
 add_definitions(-D"BUILD_REVISION=\\\"${BUILD_REVISION}\\\"")
196 196
 
197 197
 # find boost
198
-set(REQUIRED_BOOST_COMPONENTS system thread filesystem chrono)
198
+set(REQUIRED_BOOST_COMPONENTS system thread filesystem)
199 199
 if(WIN32)
200 200
     set(Boost_THREADAPI win32)
201 201
     set(framework_DEFINITIONS ${framework_DEFINITIONS} -DBOOST_THREAD_USE_LIB) # fix boost thread linkage

+ 4
- 16
src/framework/stdext/time.cpp View File

@@ -21,16 +21,12 @@
21 21
  */
22 22
 
23 23
 #include "time.h"
24
-#include <boost/chrono.hpp>
25
-#ifdef _MSC_VER
24
+#include <chrono>
26 25
 #include <thread>
27
-#else
28
-#include <unistd.h>
29
-#endif
30 26
 
31 27
 namespace stdext {
32 28
 
33
-const static auto startup_time = boost::chrono::high_resolution_clock::now();
29
+const static auto startup_time = std::chrono::high_resolution_clock::now();
34 30
 
35 31
 ticks_t time() {
36 32
     return std::time(NULL);
@@ -38,28 +34,20 @@ ticks_t time() {
38 34
 
39 35
 ticks_t millis()
40 36
 {
41
-    return boost::chrono::duration_cast<boost::chrono::milliseconds>(boost::chrono::high_resolution_clock::now() - startup_time).count();
37
+    return std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::high_resolution_clock::now() - startup_time).count();
42 38
 }
43 39
 ticks_t micros() {
44
-    return boost::chrono::duration_cast<boost::chrono::microseconds>(boost::chrono::high_resolution_clock::now() - startup_time).count();
40
+    return std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now() - startup_time).count();
45 41
 }
46 42
 
47 43
 void millisleep(size_t ms)
48 44
 {
49
-#ifdef _MSC_VER
50 45
     std::this_thread::sleep_for(std::chrono::milliseconds(ms));
51
-#else
52
-    usleep(ms * 1000);
53
-#endif
54 46
 };
55 47
 
56 48
 void microsleep(size_t us)
57 49
 {
58
-#ifdef _MSC_VER
59 50
     std::this_thread::sleep_for(std::chrono::microseconds(us));
60
-#else
61
-    usleep(us);
62
-#endif
63 51
 };
64 52
 
65 53
 }

Loading…
Cancel
Save