From: Sara Golemon Date: Wed, 10 Sep 2014 18:35:44 +0000 (-0700) Subject: Fix folly compilation on MacOSX X-Git-Tag: v0.22.0~369 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=6b5ac4feba72991143d4f07f8b602dac48e7ab22;p=folly.git 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 --- diff --git a/folly/ThreadName.h b/folly/ThreadName.h index dbcdc84e..f2b7d063 100644 --- a/folly/ThreadName.h +++ b/folly/ThreadName.h @@ -21,8 +21,16 @@ 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; diff --git a/folly/io/async/EventFDWrapper.h b/folly/io/async/EventFDWrapper.h index 294d9d37..80a81735 100644 --- a/folly/io/async/EventFDWrapper.h +++ b/folly/io/async/EventFDWrapper.h @@ -21,12 +21,24 @@ #pragma once -#include +#ifndef FOLLY_NO_CONFIG +#include +#endif + +#ifdef FOLLY_HAVE_FEATURES_H +# include +#endif + +#if defined(__GLIBC__) && !defined(__APPLE__) +#if __GLIBC_PREREQ(2, 9) +# define FOLLY_GLIBC_2_9 +#endif +#endif // doesn't exist on older glibc versions -#if (defined(__GLIBC__) && __GLIBC_PREREQ(2, 9)) +#ifdef FOLLY_GLIBC_2_9 #include -#else /* !(defined(__GLIBC__) && __GLIBC_PREREQ(2, 9)) */ +#else /* !def FOLLY_GLIBC_2_9 */ #include #include