Skip to content

Commit

Permalink
Fixes to compile on mingw32
Browse files Browse the repository at this point in the history
  • Loading branch information
edubart committed Nov 4, 2017
1 parent c9bc9e3 commit aa19f45
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/framework/CMakeLists.txt
Expand Up @@ -195,7 +195,7 @@ message(STATUS "Build revision: ${BUILD_REVISION}")
add_definitions(-D"BUILD_REVISION=\\\"${BUILD_REVISION}\\\"")

# find boost
set(REQUIRED_BOOST_COMPONENTS system thread filesystem chrono)
set(REQUIRED_BOOST_COMPONENTS system thread filesystem)
if(WIN32)
set(Boost_THREADAPI win32)
set(framework_DEFINITIONS ${framework_DEFINITIONS} -DBOOST_THREAD_USE_LIB) # fix boost thread linkage
Expand Down
20 changes: 4 additions & 16 deletions src/framework/stdext/time.cpp
Expand Up @@ -21,45 +21,33 @@
*/

#include "time.h"
#include <boost/chrono.hpp>
#ifdef _MSC_VER
#include <chrono>
#include <thread>
#else
#include <unistd.h>
#endif

namespace stdext {

const static auto startup_time = boost::chrono::high_resolution_clock::now();
const static auto startup_time = std::chrono::high_resolution_clock::now();

ticks_t time() {
return std::time(NULL);
}

ticks_t millis()
{
return boost::chrono::duration_cast<boost::chrono::milliseconds>(boost::chrono::high_resolution_clock::now() - startup_time).count();
return std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::high_resolution_clock::now() - startup_time).count();
}
ticks_t micros() {
return boost::chrono::duration_cast<boost::chrono::microseconds>(boost::chrono::high_resolution_clock::now() - startup_time).count();
return std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now() - startup_time).count();
}

void millisleep(size_t ms)
{
#ifdef _MSC_VER
std::this_thread::sleep_for(std::chrono::milliseconds(ms));
#else
usleep(ms * 1000);
#endif
};

void microsleep(size_t us)
{
#ifdef _MSC_VER
std::this_thread::sleep_for(std::chrono::microseconds(us));
#else
usleep(us);
#endif
};

}

0 comments on commit aa19f45

Please sign in to comment.