Commit fa0e7186 authored by Hannes Friederich's avatar Hannes Friederich Committed by Facebook GitHub Bot

misc fixes to support building with -Wundef

Reviewed By: Gownta

Differential Revision: D33476592

fbshipit-source-id: 9e66fdf07ce88c507cfb32406b113e1c05131c8c
parent 21329c4c
......@@ -49,7 +49,7 @@ inline void* allocateBytes(size_t n) {
}
inline void deallocateBytes(void* p, size_t n) {
#if __cpp_sized_deallocation
#if defined(__cpp_sized_deallocation)
return ::operator delete(p, n);
#else
(void)n;
......@@ -57,11 +57,12 @@ inline void deallocateBytes(void* p, size_t n) {
#endif
}
#if _POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600 || \
(defined(__ANDROID__) && (__ANDROID_API__ > 16)) || \
(defined(__APPLE__) && \
(__MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_6 || \
__IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_3_0)) || \
#if (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112L) || \
(defined(_XOPEN_SOURCE) && _XOPEN_SOURCE >= 600) || \
(defined(__ANDROID__) && (__ANDROID_API__ > 16)) || \
(defined(__APPLE__) && \
(__MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_6 || \
__IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_3_0)) || \
defined(__FreeBSD__) || defined(__wasm32__)
inline void* aligned_malloc(size_t size, size_t align) {
......@@ -118,7 +119,7 @@ void rawOverAlignedImpl(Alloc const& alloc, size_t n, void*& raw) {
static_assert(
sizeof(BaseType) == kBaseAlign && alignof(BaseType) == kBaseAlign, "");
#if __cpp_sized_deallocation
#if defined(__cpp_sized_deallocation)
if (kCanBypass && kAlign == kBaseAlign) {
// until std::allocator uses sized deallocation, it is worth the
// effort to bypass it when we are able
......@@ -357,7 +358,7 @@ std::weak_ptr<T> to_weak_ptr(const std::shared_ptr<T>& ptr) {
return ptr;
}
#if __GLIBCXX__
#if defined(__GLIBCXX__)
namespace detail {
void weak_ptr_set_stored_ptr(std::weak_ptr<void>& w, void* ptr);
......@@ -396,7 +397,7 @@ template struct GenerateWeakPtrInternalsAccessor<
*/
template <typename T, typename U>
std::weak_ptr<U> to_weak_ptr_aliasing(const std::shared_ptr<T>& r, U* ptr) {
#if __GLIBCXX__
#if defined(__GLIBCXX__)
std::weak_ptr<void> wv(r);
detail::weak_ptr_set_stored_ptr(wv, ptr);
return reinterpret_cast<std::weak_ptr<U>&&>(wv);
......
......@@ -35,7 +35,7 @@ static_assert(__GNUC__ >= 5, "__GNUC__ >= 5");
// Unaligned loads and stores
namespace folly {
#if FOLLY_HAVE_UNALIGNED_ACCESS
#if defined(FOLLY_HAVE_UNALIGNED_ACCESS) && FOLLY_HAVE_UNALIGNED_ACCESS
constexpr bool kHasUnalignedAccess = true;
#else
constexpr bool kHasUnalignedAccess = false;
......@@ -230,7 +230,7 @@ constexpr bool kIsSanitize = false;
// If the new c++ ABI is used, __cxx11 inline namespace needs to be added to
// some types, e.g. std::list.
#if _GLIBCXX_USE_CXX11_ABI
#if defined(_GLIBCXX_USE_CXX11_ABI) && _GLIBCXX_USE_CXX11_ABI
#define FOLLY_GLIBCXX_NAMESPACE_CXX11_BEGIN \
inline _GLIBCXX_BEGIN_NAMESPACE_CXX11
#define FOLLY_GLIBCXX_NAMESPACE_CXX11_END _GLIBCXX_END_NAMESPACE_CXX11
......@@ -266,10 +266,11 @@ constexpr bool kIsSanitize = false;
#endif
// Define FOLLY_HAS_EXCEPTIONS
#if __cpp_exceptions >= 199711 || FOLLY_HAS_FEATURE(cxx_exceptions)
#if (defined(__cpp_exceptions) && __cpp_exceptions >= 199711) || \
FOLLY_HAS_FEATURE(cxx_exceptions)
#define FOLLY_HAS_EXCEPTIONS 1
#elif __GNUC__
#if __EXCEPTIONS
#if defined(__EXCEPTIONS) && __EXCEPTIONS
#define FOLLY_HAS_EXCEPTIONS 1
#else // __EXCEPTIONS
#define FOLLY_HAS_EXCEPTIONS 0
......@@ -459,19 +460,19 @@ constexpr bool kIsAppleMacOS = FOLLY_APPLE_MACOS == 1;
constexpr bool kIsAppleTVOS = FOLLY_APPLE_TVOS == 1;
constexpr bool kIsAppleWatchOS = FOLLY_APPLE_WATCHOS == 1;
#if __GLIBCXX__
#if defined(__GLIBCXX__)
constexpr auto kIsGlibcxx = true;
#else
constexpr auto kIsGlibcxx = false;
#endif
#if __GLIBCXX__ && _GLIBCXX_RELEASE // major version, 7+
#if defined(__GLIBCXX__) && _GLIBCXX_RELEASE // major version, 7+
constexpr auto kGlibcxxVer = _GLIBCXX_RELEASE;
#else
constexpr auto kGlibcxxVer = 0;
#endif
#if __GLIBCXX__ && defined(_GLIBCXX_ASSERTIONS)
#if defined(__GLIBCXX__) && defined(_GLIBCXX_ASSERTIONS)
constexpr auto kGlibcxxAssertions = true;
#else
constexpr auto kGlibcxxAssertions = false;
......@@ -483,7 +484,7 @@ constexpr auto kIsLibcpp = true;
constexpr auto kIsLibcpp = false;
#endif
#if __GLIBCXX__
#if defined(__GLIBCXX__)
constexpr auto kIsLibstdcpp = true;
#else
constexpr auto kIsLibstdcpp = false;
......
......@@ -38,7 +38,7 @@
#define FOLLY_F14_VECTOR_INTRINSICS_AVAILABLE 0
#endif
#if FOLLY_SSE_PREREQ(4, 2) || __ARM_FEATURE_CRC32
#if FOLLY_SSE_PREREQ(4, 2) || defined(__ARM_FEATURE_CRC32)
#define FOLLY_F14_CRC_INTRINSIC_AVAILABLE 1
#else
#define FOLLY_F14_CRC_INTRINSIC_AVAILABLE 0
......
......@@ -36,7 +36,8 @@ inline void asm_volatile_memory() {
inline void asm_volatile_pause() {
#if defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64))
::_mm_pause();
#elif defined(__i386__) || FOLLY_X64 || (__mips_isa_rev > 1)
#elif defined(__i386__) || FOLLY_X64 || \
(defined(__mips_isa_rev) && __mips_isa_rev > 1)
asm volatile("pause");
#elif FOLLY_AARCH64 || (defined(__arm__) && !(__ARM_ARCH < 7))
asm volatile("yield");
......
......@@ -21,7 +21,8 @@
#include <folly/CPortability.h>
#include <folly/portability/Config.h>
#if (defined(USE_JEMALLOC) || FOLLY_USE_JEMALLOC) && !defined(FOLLY_SANITIZE)
#if (defined(USE_JEMALLOC) || defined(FOLLY_USE_JEMALLOC)) && \
!defined(FOLLY_SANITIZE)
#if defined(FOLLY_ASSUME_NO_JEMALLOC)
#error \
"Both USE_JEMALLOC/FOLLY_USE_JEMALLOC and FOLLY_ASSUME_NO_JEMALLOC defined"
......
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