From e9e7e81a1abf75dfbe5c729f55ff58608c47b38a Mon Sep 17 00:00:00 2001 From: mirabilos Date: Sun, 28 Jul 2019 20:30:56 +0200 Subject: [PATCH] fix memrchr detection this function is defined not on Linux but on GNU, that is, systems with glibc 2.2 or higher; also, use an intermediate HAVE_MEMRCHR symbol that people with alternative C libraries can define to indicate its presence --- util/string_util.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/util/string_util.h b/util/string_util.h index bb612a97..5977f4fd 100644 --- a/util/string_util.h +++ b/util/string_util.h @@ -41,7 +41,13 @@ inline int strncasecmp(const char* s1, const char* s2, size_t n) { #endif } -#if !defined(__linux__) +#ifndef HAVE_MEMRCHR +#if defined(__GLIBC__) && ((__GLIBC__ > 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 2))) +#define HAVE_MEMRCHR +#endif +#endif + +#ifndef HAVE_MEMRCHR inline void* memrchr(const void* s, int c, size_t n) { const unsigned char* p = (const unsigned char*) s; for (p += n; n > 0; n--) {