Commit 40eff3a7 authored by Michael Lee (Engineering)'s avatar Michael Lee (Engineering) Committed by Facebook GitHub Bot

Add `constexpr` to Portability for Apple OS targets

Summary:
Before: While the Xcode constants are pretty well standardized, discoverability and use within folly is non-trivial.
We have constants for various other attributes about the OS and target platform, so add a sane mapping for Apple targets as well.

Reviewed By: yfeldblum

Differential Revision: D23605949

fbshipit-source-id: cd4212dd30d9ec6a3c48a6d7a787a67fdeb9dd1f
parent 5f813e67
...@@ -383,11 +383,6 @@ using namespace FOLLY_GFLAGS_NAMESPACE; ...@@ -383,11 +383,6 @@ using namespace FOLLY_GFLAGS_NAMESPACE;
} // namespace gflags } // namespace gflags
#endif #endif
// for TARGET_OS_IPHONE
#ifdef __APPLE__
#include <TargetConditionals.h> // @manual
#endif
// RTTI may not be enabled for this compilation unit. // RTTI may not be enabled for this compilation unit.
#if defined(__GXX_RTTI) || defined(__cpp_rtti) || \ #if defined(__GXX_RTTI) || defined(__cpp_rtti) || \
(defined(_MSC_VER) && defined(_CPPRTTI)) (defined(_MSC_VER) && defined(_CPPRTTI))
...@@ -409,6 +404,30 @@ constexpr bool const kHasRtti = FOLLY_HAS_RTTI; ...@@ -409,6 +404,30 @@ constexpr bool const kHasRtti = FOLLY_HAS_RTTI;
#define FOLLY_STATIC_CTOR_PRIORITY_MAX __attribute__((__init_priority__(102))) #define FOLLY_STATIC_CTOR_PRIORITY_MAX __attribute__((__init_priority__(102)))
#endif #endif
#if defined(__APPLE__) && TARGET_OS_IOS
#define FOLLY_APPLE_IOS 1
#else
#define FOLLY_APPLE_IOS 0
#endif
#if defined(__APPLE__) && TARGET_OS_OSX
#define FOLLY_APPLE_MACOS 1
#else
#define FOLLY_APPLE_MACOS 0
#endif
#if defined(__APPLE__) && TARGET_OS_TV
#define FOLLY_APPLE_TVOS 1
#else
#define FOLLY_APPLE_TVOS 0
#endif
#if defined(__APPLE__) && TARGET_OS_WATCH
#define FOLLY_APPLE_WATCHOS 1
#else
#define FOLLY_APPLE_WATCHOS 0
#endif
namespace folly { namespace folly {
#if __OBJC__ #if __OBJC__
...@@ -435,6 +454,11 @@ constexpr auto kIsWindows = true; ...@@ -435,6 +454,11 @@ constexpr auto kIsWindows = true;
constexpr auto kIsWindows = false; constexpr auto kIsWindows = false;
#endif #endif
constexpr bool kIsAppleIOS = FOLLY_APPLE_IOS == 1;
constexpr bool kIsAppleMacOS = FOLLY_APPLE_MACOS == 1;
constexpr bool kIsAppleTVOS = FOLLY_APPLE_TVOS == 1;
constexpr bool kIsAppleWatchOS = FOLLY_APPLE_WATCHOS == 1;
#if __GLIBCXX__ #if __GLIBCXX__
constexpr auto kIsGlibcxx = true; constexpr auto kIsGlibcxx = true;
#else #else
......
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