Summary:
We don't always have features.h
and our glibc doesn't have __GLIBC_PREREQ()
@override-unit-failures
Test Plan: Builds on MacOSX
Reviewed By: pt@fb.com
Subscribers: njormrod
FB internal diff:
D1546679
namespace folly {
+// This looks a bit weird, but it's necessary to avoid
+// having an undefined compiler function called.
+#if defined(__GLIBC__) && !defined(__APPLE__)
+#if __GLIBC_PREREQ(2, 12)
+# define FOLLY_GLIBC_2_12
+#endif
+#endif
+
inline bool setThreadName(pthread_t id, StringPiece name) {
-#if (defined(__GLIBC__) && __GLIBC_PREREQ(2, 12))
+#ifdef FOLLY_GLIBC_2_12
return 0 == pthread_setname_np(id, name.fbstr().substr(0, 15).c_str());
#else
return false;
#pragma once
-#include <features.h>
+#ifndef FOLLY_NO_CONFIG
+#include <folly/folly-config.h>
+#endif
+
+#ifdef FOLLY_HAVE_FEATURES_H
+# include <features.h>
+#endif
+
+#if defined(__GLIBC__) && !defined(__APPLE__)
+#if __GLIBC_PREREQ(2, 9)
+# define FOLLY_GLIBC_2_9
+#endif
+#endif
// <sys/eventfd.h> doesn't exist on older glibc versions
-#if (defined(__GLIBC__) && __GLIBC_PREREQ(2, 9))
+#ifdef FOLLY_GLIBC_2_9
#include <sys/eventfd.h>
-#else /* !(defined(__GLIBC__) && __GLIBC_PREREQ(2, 9)) */
+#else /* !def FOLLY_GLIBC_2_9 */
#include <sys/syscall.h>
#include <unistd.h>