folly/portability/Memory.cpp: restructure preprocessor conditionals so includes are...
authorYiding Jia <yiding@fb.com>
Sun, 28 May 2017 18:51:10 +0000 (11:51 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Sun, 28 May 2017 19:04:52 +0000 (12:04 -0700)
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

folly/portability/Memory.cpp

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