Use std::thread rather than pthreads in AtomicHashMapTest
[folly.git] / folly / Memory.h
index bcfa321c8635d6d20a411e1b828366cea1e4cb98..81ac176cb11a3494923ff5f378844472f0f1f926 100644 (file)
  * limitations under the License.
  */
 
-#ifndef FOLLY_MEMORY_H_
-#define FOLLY_MEMORY_H_
+#pragma once
 
 #include <folly/Traits.h>
+#include <folly/portability/Memory.h>
 
 #include <cstddef>
 #include <cstdlib>
@@ -37,8 +37,9 @@ namespace folly {
  * @author Xu Ning (xning@fb.com)
  */
 
-#if __cplusplus >= 201402L || \
-    defined __cpp_lib_make_unique && __cpp_lib_make_unique >= 201304L
+#if __cplusplus >= 201402L ||                                              \
+    (defined __cpp_lib_make_unique && __cpp_lib_make_unique >= 201304L) || \
+    (defined(_MSC_VER) && _MSC_VER >= 1900)
 
 /* using override */ using std::make_unique;
 
@@ -113,6 +114,12 @@ std::shared_ptr<T> to_shared_ptr(std::unique_ptr<T, D>&& ptr) {
   return std::shared_ptr<T>(std::move(ptr));
 }
 
+using SysBufferDeleter = static_function_deleter<void, ::free>;
+using SysBufferUniquePtr = std::unique_ptr<void, SysBufferDeleter>;
+inline SysBufferUniquePtr allocate_sys_buffer(size_t size) {
+  return SysBufferUniquePtr(::malloc(size));
+}
+
 /**
  * A SimpleAllocator must provide two methods:
  *
@@ -417,5 +424,3 @@ std::shared_ptr<T> allocate_shared(Allocator&& allocator, Args&&... args) {
 template <class T> struct IsArenaAllocator : std::false_type { };
 
 }  // namespace folly
-
-#endif /* FOLLY_MEMORY_H_ */