Use FOLLY_DEPRECATED rather than directly using GCC specific attributes.
[folly.git] / folly / Portability.h
index c059a3cb34d2831883f21f472c0f1f1c52401836..63318a2ce3a2ae14783dc5f265071760b1756bd5 100644 (file)
 #ifndef FOLLY_PORTABILITY_H_
 #define FOLLY_PORTABILITY_H_
 
+// @nocommit invalidate ccache 20151125 (see #8764509)
+
+#include <string.h>
+
 #include <cstddef>
 
 #ifndef FOLLY_NO_CONFIG
  #endif
 #endif
 
+#ifndef FOLLY_HAVE_UNALIGNED_READS
+#define FOLLY_HAVE_UNALIGNED_READS 0
+#endif
+
 // A change in folly/MemoryMapping.cpp uses MAP_ANONYMOUS, which is named
 // MAP_ANON on OSX/BSD.
 #if defined(__APPLE__) || defined(__FreeBSD__)
 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__
+/* nolint */
+#  define __CLANG_PREREQ(maj, min) \
+    ((__clang_major__ << 16) + __clang_minor__ >= ((maj) << 16) + (min))
+# else
+/* nolint */
+#  define __CLANG_PREREQ(maj, min) 0
+# endif
+#endif
+
 /* Platform specific TLS support
  * gcc implements __thread
  * msvc implements __declspec(thread)
@@ -375,6 +395,22 @@ inline void asm_pause() {
 #endif
 }
 
+constexpr size_t constexpr_strlen(const char* s) {
+#if defined(__clang__)
+  return __builtin_strlen(s);
+#else
+  return strlen(s);
+#endif
 }
 
+#if defined(__APPLE__) || defined(_MSC_VER)
+#define MAX_STATIC_CONSTRUCTOR_PRIORITY
+#else
+// 101 is the highest priority allowed by the init_priority attribute.
+// This priority is already used by JEMalloc and other memory allocators so
+// we will take the next one.
+#define MAX_STATIC_CONSTRUCTOR_PRIORITY __attribute__ ((__init_priority__(102)))
+#endif
+
+} // namespace folly
 #endif // FOLLY_PORTABILITY_H_