An intro to the upgrade mutex in the Synchronized docs
[folly.git] / folly / Portability.h
index 2d3ec417c3f32210679d692e3c7e7d35871b93a2..12cff605f58128841d4a8f6967ca7f6037bc4905 100644 (file)
@@ -92,6 +92,15 @@ constexpr bool kHasUnalignedAccess = false;
 # define FOLLY_ALWAYS_INLINE inline
 #endif
 
+// warn unused result
+#if defined(_MSC_VER) && (_MSC_VER >= 1700)
+#define FOLLY_WARN_UNUSED_RESULT _Check_return_
+#elif defined(__clang__) || defined(__GNUC__)
+#define FOLLY_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__))
+#else
+#define FOLLY_WARN_UNUSED_RESULT
+#endif
+
 // target
 #ifdef _MSC_VER
 # define FOLLY_TARGET_ATTRIBUTE(target)
@@ -229,35 +238,6 @@ namespace std { typedef ::max_align_t max_align_t; }
 # define FOLLY_GLIBCXX_NAMESPACE_CXX11_END
 #endif
 
-// Provide our own std::__throw_* wrappers for platforms that don't have them
-#if FOLLY_HAVE_BITS_FUNCTEXCEPT_H
-#include <bits/functexcept.h>
-#else
-#include <folly/detail/FunctionalExcept.h>
-#endif
-
-#if defined(__cplusplus)
-// Unfortunately, boost::has_trivial_copy<T> is broken in libc++ due to its
-// usage of __has_trivial_copy(), so we can't use it as a
-// least-common-denominator for C++11 implementations that don't support
-// std::is_trivially_copyable<T>.
-//
-//      http://stackoverflow.com/questions/12754886/has-trivial-copy-behaves-differently-in-clang-and-gcc-whos-right
-//
-// As a result, use std::is_trivially_copyable() where it exists, and fall back
-// to Boost otherwise.
-#if FOLLY_HAVE_STD__IS_TRIVIALLY_COPYABLE
-#include <type_traits>
-#define FOLLY_IS_TRIVIALLY_COPYABLE(T)                   \
-  (std::is_trivially_copyable<T>::value)
-#else
-#include <boost/type_traits.hpp>
-#define FOLLY_IS_TRIVIALLY_COPYABLE(T)                   \
-  (boost::has_trivial_copy<T>::value &&                  \
-   boost::has_trivial_destructor<T>::value)
-#endif
-#endif // __cplusplus
-
 // MSVC specific defines
 // mainly for posix compat
 #ifdef _MSC_VER
@@ -354,3 +334,12 @@ using namespace FOLLY_GFLAGS_NAMESPACE;
 // we will take the next one.
 #define FOLLY_STATIC_CTOR_PRIORITY_MAX __attribute__((__init_priority__(102)))
 #endif
+
+namespace folly {
+
+#if defined(__linux__) && !FOLLY_MOBILE
+constexpr auto kIsLinux = true;
+#else
+constexpr auto kIsLinux = false;
+#endif
+}