Skip to content

Commit

Permalink
fix memrchr detection
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mirabilos committed Jul 29, 2019
1 parent 1193457 commit e9e7e81
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion util/string_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -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--) {
Expand Down

0 comments on commit e9e7e81

Please sign in to comment.