Use Baton (again) in EventBase::runInEventBaseThreadAndWait
[folly.git] / folly / Portability.h
index 51032fdacd43addc99388e9f765cca2e246e77a4..053b5b1632b57004db715d80be899671c24830a4 100644 (file)
@@ -52,7 +52,7 @@ constexpr bool kHasUnalignedAccess = false;
 # endif
 /* nolint */
 # define _USE_ATTRIBUTES_FOR_SAL 1
-# include <sal.h>
+# include <sal.h> // @manual
 # define FOLLY_PRINTF_FORMAT _Printf_format_string_
 # define FOLLY_PRINTF_FORMAT_ATTR(format_param, dots_param) /**/
 #else
@@ -71,12 +71,19 @@ constexpr bool kHasUnalignedAccess = false;
 #endif
 
 // warn unused result
+#if defined(__has_cpp_attribute)
+#if __has_cpp_attribute(nodiscard)
+#define FOLLY_NODISCARD [[nodiscard]]
+#endif
+#endif
+#if !defined FOLLY_NODISCARD
 #if defined(_MSC_VER) && (_MSC_VER >= 1700)
-#define FOLLY_WARN_UNUSED_RESULT _Check_return_
+#define FOLLY_NODISCARD _Check_return_
 #elif defined(__clang__) || defined(__GNUC__)
-#define FOLLY_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__))
+#define FOLLY_NODISCARD __attribute__((__warn_unused_result__))
 #else
-#define FOLLY_WARN_UNUSED_RESULT
+#define FOLLY_NODISCARD
+#endif
 #endif
 
 // target
@@ -172,13 +179,6 @@ constexpr bool kIsSanitizeThread = false;
 #define FOLLY_GCC_DISABLE_NEW_SHADOW_WARNINGS /* empty */
 #endif
 
-#if defined(__GNUC__) && !defined(__APPLE__) && !__GNUC_PREREQ(4,9)
-// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56019
-// gcc 4.8.x incorrectly placed max_align_t in the root namespace
-// Alias it into std (where it's found in 4.9 and later)
-namespace std { typedef ::max_align_t max_align_t; }
-#endif
-
 // portable version check for clang
 #ifndef __CLANG_PREREQ
 # if defined __clang__ && defined __clang_major__ && defined __clang_minor__
@@ -213,7 +213,7 @@ namespace std { typedef ::max_align_t max_align_t; }
 // the 'std' namespace; the latter uses inline namespaces. Wrap this decision
 // up in a macro to make forward-declarations easier.
 #if FOLLY_USE_LIBCPP
-#include <__config>
+#include <__config> // @manual
 #define FOLLY_NAMESPACE_STD_BEGIN     _LIBCPP_BEGIN_NAMESPACE_STD
 #define FOLLY_NAMESPACE_STD_END       _LIBCPP_END_NAMESPACE_STD
 #else
@@ -311,7 +311,7 @@ using namespace FOLLY_GFLAGS_NAMESPACE;
 
 // for TARGET_OS_IPHONE
 #ifdef __APPLE__
-#include <TargetConditionals.h>
+#include <TargetConditionals.h> // @manual
 #endif
 
 // RTTI may not be enabled for this compilation unit.
@@ -345,7 +345,9 @@ constexpr auto kIsLinux = false;
 
 #if defined(_WIN32)
 constexpr auto kIsWindows = true;
+constexpr auto kMscVer = _MSC_VER;
 #else
 constexpr auto kIsWindows = false;
+constexpr auto kMscVer = 0;
 #endif
 }