Only try to use the membarrier on Linux
[folly.git] / folly / Memory.h
index 193d5062834931688ac4d502abcbf30734209f45..81ac176cb11a3494923ff5f378844472f0f1f926 100644 (file)
@@ -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:
  *