Commit 6edcf484 authored by Christopher Dykes's avatar Christopher Dykes Committed by Facebook Github Bot 5

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
parent 59bcc452
...@@ -22,22 +22,31 @@ ...@@ -22,22 +22,31 @@
#include <folly/Conv.h> #include <folly/Conv.h>
#include <folly/portability/SysSyscall.h> #include <folly/portability/SysSyscall.h>
#include <folly/portability/Unistd.h> #include <folly/portability/Unistd.h>
#include <folly/portability/Windows.h>
#include <chrono> #include <chrono>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/utsname.h>
#include <errno.h> #include <errno.h>
#include <glog/logging.h> #include <glog/logging.h>
#include <fcntl.h> #include <fcntl.h>
#include <stdio.h> #include <stdio.h>
#include <stdexcept> #include <stdexcept>
#ifndef _MSC_VER
#include <sys/utsname.h>
#endif
using std::string; using std::string;
using namespace std::chrono; using namespace std::chrono;
namespace folly { namespace folly {
#ifdef _MSC_VER
static pid_t gettid() {
return pid_t(GetCurrentThreadId());
}
#else
/** /**
* glibc doesn't provide gettid(), so define it ourselves. * glibc doesn't provide gettid(), so define it ourselves.
*/ */
...@@ -105,6 +114,7 @@ static int64_t determineJiffiesHZ() { ...@@ -105,6 +114,7 @@ static int64_t determineJiffiesHZ() {
return hz; return hz;
} }
#endif
/** /**
* Determine how long this process has spent waiting to get scheduled on the * Determine how long this process has spent waiting to get scheduled on the
...@@ -114,6 +124,9 @@ static int64_t determineJiffiesHZ() { ...@@ -114,6 +124,9 @@ static int64_t determineJiffiesHZ() {
* time cannot be determined. * time cannot be determined.
*/ */
static milliseconds getTimeWaitingMS(pid_t tid) { static milliseconds getTimeWaitingMS(pid_t tid) {
#ifdef _MSC_VER
return milliseconds(0);
#else
static int64_t jiffiesHZ = 0; static int64_t jiffiesHZ = 0;
if (jiffiesHZ == 0) { if (jiffiesHZ == 0) {
jiffiesHZ = determineJiffiesHZ(); jiffiesHZ = determineJiffiesHZ();
...@@ -168,6 +181,7 @@ static milliseconds getTimeWaitingMS(pid_t tid) { ...@@ -168,6 +181,7 @@ static milliseconds getTimeWaitingMS(pid_t tid) {
LOG(ERROR) << "error determining process wait time: %s" << e.what(); LOG(ERROR) << "error determining process wait time: %s" << e.what();
return milliseconds(0); return milliseconds(0);
} }
#endif
} }
void TimePoint::reset() { void TimePoint::reset() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment