-/* Define a convenience macro to test when address sanitizer is being used
- * across the different compilers (e.g. clang, gcc) */
-#if defined(__clang__)
-# if __has_feature(address_sanitizer)
-# define FOLLY_SANITIZE_ADDRESS 1
-# endif
-#elif defined (__GNUC__) && \
- (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 8)) || (__GNUC__ >= 5)) && \
- __SANITIZE_ADDRESS__
-# define FOLLY_SANITIZE_ADDRESS 1
-#endif
-
-/* Define attribute wrapper for function attribute used to disable
- * address sanitizer instrumentation. Unfortunately, this attribute
- * has issues when inlining is used, so disable that as well. */
-#ifdef FOLLY_SANITIZE_ADDRESS
-# if defined(__clang__)
-# if __has_attribute(__no_address_safety_analysis__)
-# define FOLLY_DISABLE_ADDRESS_SANITIZER \
- __attribute__((__no_address_safety_analysis__, __noinline__))
-# elif __has_attribute(__no_sanitize_address__)
-# define FOLLY_DISABLE_ADDRESS_SANITIZER \
- __attribute__((__no_sanitize_address__, __noinline__))
-# endif
-# elif defined(__GNUC__)
-# define FOLLY_DISABLE_ADDRESS_SANITIZER \
- __attribute__((__no_address_safety_analysis__, __noinline__))
+// 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
+
+// this definition is in a really silly place with a silly name
+// and ifdefing it every time we want it is painful
+#include <basetsd.h>
+typedef SSIZE_T ssize_t;
+
+// sprintf semantics are not exactly identical
+// but current usage is not a problem
+# define snprintf _snprintf
+
+// semantics here are identical
+# define strerror_r(errno,buf,len) strerror_s(buf,len,errno)
+
+// compiler specific to compiler specific
+// nolint
+# define __PRETTY_FUNCTION__ __FUNCSIG__
+
+// Hide a GCC specific thing that breaks MSVC if left alone.
+# define __extension__
+
+#ifdef _M_IX86_FP
+# define FOLLY_SSE _M_IX86_FP
+# define FOLLY_SSE_MINOR 0
+#endif
+
+#endif
+
+#ifndef FOLLY_SSE
+# if defined(__SSE4_2__)
+# define FOLLY_SSE 4
+# define FOLLY_SSE_MINOR 2
+# elif defined(__SSE4_1__)
+# define FOLLY_SSE 4
+# define FOLLY_SSE_MINOR 1
+# elif defined(__SSE4__)
+# define FOLLY_SSE 4
+# define FOLLY_SSE_MINOR 0
+# elif defined(__SSE3__)
+# define FOLLY_SSE 3
+# define FOLLY_SSE_MINOR 0
+# elif defined(__SSE2__)
+# define FOLLY_SSE 2
+# define FOLLY_SSE_MINOR 0
+# elif defined(__SSE__)
+# define FOLLY_SSE 1
+# define FOLLY_SSE_MINOR 0
+# else
+# define FOLLY_SSE 0
+# define FOLLY_SSE_MINOR 0