From: Christopher Dykes Date: Thu, 4 Aug 2016 17:49:23 +0000 (-0700) Subject: Support TimeUtil under MSVC X-Git-Tag: v2016.08.08.00~21 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=6edcf4846b89fc34cbd62b88b049fd4b9f1aad85;p=folly.git Support TimeUtil under MSVC Summary: Well, make it compile anyways. There's no simple equivelant for Windows, so just return 0 instead. Reviewed By: yfeldblum Differential Revision: D3667474 fbshipit-source-id: 02224c6666dfcfdec237bfbbd4714170407a952a --- diff --git a/folly/io/async/test/TimeUtil.cpp b/folly/io/async/test/TimeUtil.cpp index 8103fcc5..6db4964b 100644 --- a/folly/io/async/test/TimeUtil.cpp +++ b/folly/io/async/test/TimeUtil.cpp @@ -22,22 +22,31 @@ #include #include #include +#include #include #include #include -#include #include #include #include #include #include +#ifndef _MSC_VER +#include +#endif + using std::string; using namespace std::chrono; namespace folly { +#ifdef _MSC_VER +static pid_t gettid() { + return pid_t(GetCurrentThreadId()); +} +#else /** * glibc doesn't provide gettid(), so define it ourselves. */ @@ -105,6 +114,7 @@ static int64_t determineJiffiesHZ() { return hz; } +#endif /** * Determine how long this process has spent waiting to get scheduled on the @@ -114,6 +124,9 @@ static int64_t determineJiffiesHZ() { * time cannot be determined. */ static milliseconds getTimeWaitingMS(pid_t tid) { +#ifdef _MSC_VER + return milliseconds(0); +#else static int64_t jiffiesHZ = 0; if (jiffiesHZ == 0) { jiffiesHZ = determineJiffiesHZ(); @@ -168,6 +181,7 @@ static milliseconds getTimeWaitingMS(pid_t tid) { LOG(ERROR) << "error determining process wait time: %s" << e.what(); return milliseconds(0); } +#endif } void TimePoint::reset() {