From: Sean Cannella Date: Wed, 3 Jul 2013 20:36:28 +0000 (-0700) Subject: memrchr and *timed_mutex are platform-specific X-Git-Tag: v0.22.0~935 X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=b1463f8f7e68895866b62913997423feb338aeb1;p=folly.git memrchr and *timed_mutex are platform-specific Summary: - conditionally compile rfind overrides - conditionally add support for timed_mutex/recursive_timed_mutex Test Plan: - compiled on OSX - unit tests Reviewed By: andrei.alexandrescu@fb.com FB internal diff: D872272 --- diff --git a/folly/Range.h b/folly/Range.h index 2c26db07..85a554c5 100644 --- a/folly/Range.h +++ b/folly/Range.h @@ -705,12 +705,14 @@ inline size_t qfind(const Range& haystack, const char& needle) { return pos == nullptr ? std::string::npos : pos - haystack.data(); } +#ifdef _GNU_SOURCE // memrchr is a GNU extension template <> inline size_t rfind(const Range& haystack, const char& needle) { auto pos = static_cast( ::memrchr(haystack.data(), needle, haystack.size())); return pos == nullptr ? std::string::npos : pos - haystack.data(); } +#endif // specialization for ByteRange template <> @@ -721,6 +723,7 @@ inline size_t qfind(const Range& haystack, return pos == nullptr ? std::string::npos : pos - haystack.data(); } +#ifdef _GNU_SOURCE // memrchr is a GNU extension template <> inline size_t rfind(const Range& haystack, const unsigned char& needle) { @@ -728,6 +731,7 @@ inline size_t rfind(const Range& haystack, ::memrchr(haystack.data(), needle, haystack.size())); return pos == nullptr ? std::string::npos : pos - haystack.data(); } +#endif template size_t qfind_first_of(const Range& haystack, diff --git a/folly/Synchronized.h b/folly/Synchronized.h index ea1cb84d..cc43071a 100644 --- a/folly/Synchronized.h +++ b/folly/Synchronized.h @@ -48,9 +48,11 @@ template struct HasLockUnlock { enum { value = IsOneOf::value }; }; @@ -95,6 +97,7 @@ acquireReadWrite(T& mutex) { mutex.lock(); } +#ifndef __APPLE__ // OSX doesn't have timed mutexes /** * Acquires a mutex for reading and writing with timeout by calling * .try_lock_for(). This applies to two of the std mutex classes as @@ -121,6 +124,7 @@ acquireReadWrite(T& mutex, unsigned int milliseconds) { return mutex.timed_lock(boost::posix_time::milliseconds(milliseconds)); } +#endif // __APPLE__ /** * Releases a mutex previously acquired for reading by calling