X-Git-Url: http://git.efficios.com/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fcommon%2Fcompat%2Fstring.h;h=a7bcab0a8c345a6e34019b2419d424207372be10;hp=7c426ef3de3bd97e5056ef469f6db6cb528b1c61;hb=6ec9dc48cf7f3d5e1fc01f741197c0bacc94bbf0;hpb=afc5df0361caae100946d58aa557433891d52cb3 diff --git a/src/common/compat/string.h b/src/common/compat/string.h index 7c426ef3d..a7bcab0a8 100644 --- a/src/common/compat/string.h +++ b/src/common/compat/string.h @@ -117,11 +117,31 @@ static inline int lttng_fls(int val) r -= 2; } if (!(x & 0x80000000U)) { - x <<= 1; r -= 1; } return r; } #endif /* HAVE_FLS */ +#if HAVE_MEMRCHR +static inline +void *lttng_memrchr(const void *s, int c, size_t n) +{ + return memrchr(s, c, n); +} +#else +static inline +void *lttng_memrchr(const void *s, int c, size_t n) +{ + int i; + const char *str = s; + for (i = n-1; i >= 0; i--) { + if (str[i] == (char)c) { + return (void *)(str+i); + } + } + return NULL; +} +#endif /* HAVE_MEMRCHR */ + #endif /* _COMPAT_STRING_H */