Support PicoSpinLock on MSVC
[folly.git] / folly / Random.cpp
index d1584f11edaa1de1f94351ab58816c299f100ebf..c6b611be181346d5b489851b710f5af22a24a5f2 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2015 Facebook, Inc.
+ * Copyright 2016 Facebook, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 #include <folly/Random.h>
 
 #include <atomic>
-#include <unistd.h>
-#include <sys/time.h>
 #include <mutex>
 #include <random>
 #include <array>
 
 #include <glog/logging.h>
+#include <folly/CallOnce.h>
 #include <folly/File.h>
 #include <folly/FileUtil.h>
 #include <folly/ThreadLocal.h>
+#include <folly/portability/SysTime.h>
+#include <folly/portability/Unistd.h>
 
 #ifdef _MSC_VER
 # include <wincrypt.h>
@@ -38,9 +39,9 @@ namespace {
 
 void readRandomDevice(void* data, size_t size) {
 #ifdef _MSC_VER
-  static std::once_flag flag;
+  static folly::once_flag flag;
   static HCRYPTPROV cryptoProv;
-  std::call_once(flag, [&] {
+  folly::call_once(flag, [&] {
     PCHECK(CryptAcquireContext(&cryptoProv, nullptr, nullptr,
                                PROV_RSA_FULL, 0));
   });