Commit 6b5ac4fe authored by Sara Golemon's avatar Sara Golemon

Fix folly compilation on MacOSX

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
parent b229d828
...@@ -21,8 +21,16 @@ ...@@ -21,8 +21,16 @@
namespace folly { 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) { 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()); return 0 == pthread_setname_np(id, name.fbstr().substr(0, 15).c_str());
#else #else
return false; return false;
......
...@@ -21,12 +21,24 @@ ...@@ -21,12 +21,24 @@
#pragma once #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 // <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> #include <sys/eventfd.h>
#else /* !(defined(__GLIBC__) && __GLIBC_PREREQ(2, 9)) */ #else /* !def FOLLY_GLIBC_2_9 */
#include <sys/syscall.h> #include <sys/syscall.h>
#include <unistd.h> #include <unistd.h>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment