fix folly Range compilation on FreeBSD
authorSean Cannella <seanc@fb.com>
Mon, 29 Jul 2013 19:36:55 +0000 (12:36 -0700)
committerSara Golemon <sgolemon@fb.com>
Wed, 28 Aug 2013 21:30:11 +0000 (14:30 -0700)
Summary: - memrchr is GNU + Linux specific, it turns out

Test Plan: - compiled on FreeBSD, contbuild

Reviewed By: delong.j@fb.com

FB internal diff: D900935

folly/Range.h
folly/configure.ac

index 85a554c5919d9289555e7df437de2c80c869683a..a1cce77f4a995deea7e0dcfb1ceee93a7b8632ab 100644 (file)
@@ -705,7 +705,7 @@ inline size_t qfind(const Range<const char*>& haystack, const char& needle) {
   return pos == nullptr ? std::string::npos : pos - haystack.data();
 }
 
-#ifdef _GNU_SOURCE // memrchr is a GNU extension
+#if FOLLY_HAVE_MEMRCHR
 template <>
 inline size_t rfind(const Range<const char*>& haystack, const char& needle) {
   auto pos = static_cast<const char*>(
@@ -723,7 +723,7 @@ inline size_t qfind(const Range<const unsigned char*>& haystack,
   return pos == nullptr ? std::string::npos : pos - haystack.data();
 }
 
-#ifdef _GNU_SOURCE // memrchr is a GNU extension
+#if FOLLY_HAVE_MEMRCHR
 template <>
 inline size_t rfind(const Range<const unsigned char*>& haystack,
                     const unsigned char& needle) {
index 33ac2e8ecb933c5ad096bddf7a4a206ed221ae61..8d5765c13b40a44251c58b48dbe9c3c109475ad1 100644 (file)
@@ -86,7 +86,8 @@ AC_CHECK_FUNCS([getdelim \
                 pthread_yield \
                 rallocm \
                 malloc_size \
-                malloc_usable_size])
+                malloc_usable_size \
+                memrchr])
 
 if test "$ac_cv_func_pthread_yield" = "no"; then
    AC_CHECK_HEADERS([sched.h])