Commit 3a78d442 authored by Yiding Jia's avatar Yiding Jia Committed by Facebook Github Bot

folly/portability/Memory.cpp: restructure preprocessor conditionals so includes are at top level

Summary:
`#include` inside a namespace is disallowed when using clang modules. Here I
just unconditionally include them at top level, since they are available in all the
relevant platforms.

Reviewed By: yfeldblum, Orvid

Differential Revision: D5140355

fbshipit-source-id: bb87225c1d8f4ac64b90a7aff5f912c13e150e3a
parent c1a1a5e6
...@@ -17,6 +17,9 @@ ...@@ -17,6 +17,9 @@
#include <folly/portability/Memory.h> #include <folly/portability/Memory.h>
#include <folly/portability/Config.h> #include <folly/portability/Config.h>
#include <folly/portability/Malloc.h>
#include <errno.h>
namespace folly { namespace folly {
namespace detail { namespace detail {
...@@ -24,7 +27,6 @@ namespace detail { ...@@ -24,7 +27,6 @@ namespace detail {
(defined(__ANDROID__) && (__ANDROID_API__ > 15)) || \ (defined(__ANDROID__) && (__ANDROID_API__ > 15)) || \
(defined(__APPLE__) && (__MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_6 || \ (defined(__APPLE__) && (__MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_6 || \
__IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_3_0)) __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_3_0))
#include <errno.h>
// Use posix_memalign, but mimic the behaviour of memalign // Use posix_memalign, but mimic the behaviour of memalign
void* aligned_malloc(size_t size, size_t align) { void* aligned_malloc(size_t size, size_t align) {
...@@ -41,7 +43,6 @@ void aligned_free(void* aligned_ptr) { ...@@ -41,7 +43,6 @@ void aligned_free(void* aligned_ptr) {
free(aligned_ptr); free(aligned_ptr);
} }
#elif defined(_WIN32) #elif defined(_WIN32)
#include <malloc.h> // nolint
void* aligned_malloc(size_t size, size_t align) { void* aligned_malloc(size_t size, size_t align) {
return _aligned_malloc(size, align); return _aligned_malloc(size, align);
...@@ -51,7 +52,6 @@ void aligned_free(void* aligned_ptr) { ...@@ -51,7 +52,6 @@ void aligned_free(void* aligned_ptr) {
_aligned_free(aligned_ptr); _aligned_free(aligned_ptr);
} }
#else #else
#include <malloc.h> // nolint
void* aligned_malloc(size_t size, size_t align) { void* aligned_malloc(size_t size, size_t align) {
return memalign(align, size); return memalign(align, size);
......
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