X-Git-Url: http://git.efficios.com/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fcommon%2Fcompat%2Fstring.h;h=a7bcab0a8c345a6e34019b2419d424207372be10;hp=db3db80522f5fe039f3f5f716f567f6676dfa87f;hb=4b223a6755662f272f7db155ee380528728e5dd1;hpb=b3f35e021305afc1a40b9f3637c77595f38d6df2 diff --git a/src/common/compat/string.h b/src/common/compat/string.h index db3db8052..a7bcab0a8 100644 --- a/src/common/compat/string.h +++ b/src/common/compat/string.h @@ -123,4 +123,25 @@ static inline int lttng_fls(int val) } #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 */