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
return pos == nullptr ? std::string::npos : pos - haystack.data();
}
+#ifdef _GNU_SOURCE // memrchr is a GNU extension
template <>
inline size_t rfind(const Range<const char*>& haystack, const char& needle) {
auto pos = static_cast<const char*>(
::memrchr(haystack.data(), needle, haystack.size()));
return pos == nullptr ? std::string::npos : pos - haystack.data();
}
+#endif
// specialization for ByteRange
template <>
return pos == nullptr ? std::string::npos : pos - haystack.data();
}
+#ifdef _GNU_SOURCE // memrchr is a GNU extension
template <>
inline size_t rfind(const Range<const unsigned char*>& haystack,
const unsigned char& needle) {
::memrchr(haystack.data(), needle, haystack.size()));
return pos == nullptr ? std::string::npos : pos - haystack.data();
}
+#endif
template <class T>
size_t qfind_first_of(const Range<T>& haystack,
struct HasLockUnlock {
enum { value = IsOneOf<T,
std::mutex, std::recursive_mutex,
- std::timed_mutex, std::recursive_timed_mutex,
boost::mutex, boost::recursive_mutex, boost::shared_mutex,
+#ifndef __APPLE__ // OSX doesn't have timed mutexes
+ std::timed_mutex, std::recursive_timed_mutex,
boost::timed_mutex, boost::recursive_timed_mutex
+#endif
>::value };
};
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
unsigned int milliseconds) {
return mutex.timed_lock(boost::posix_time::milliseconds(milliseconds));
}
+#endif // __APPLE__
/**
* Releases a mutex previously acquired for reading by calling