From 4bc7ef12668e1652419ec21efa264e10592a4317 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fran=C3=A7ois=20Tigeot?= Date: Sat, 14 Nov 2015 15:19:47 +0100 Subject: [PATCH] drm: Import memchr_inv() from NetBSD --- sys/dev/drm/include/linux/string.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/sys/dev/drm/include/linux/string.h b/sys/dev/drm/include/linux/string.h index 99a455a5a2..2cdde6e597 100644 --- a/sys/dev/drm/include/linux/string.h +++ b/sys/dev/drm/include/linux/string.h @@ -38,6 +38,20 @@ #define strnicmp strncasecmp +#define __UNCONST(a) ((void *)(unsigned long)(const void *)(a)) + +static inline void * +memchr_inv(const void *buffer, int c, size_t len) +{ + const uint8_t byte = c; /* XXX lose */ + const char *p; + + for (p = buffer; len-- > 0; p++) + if (*p != byte) + return __UNCONST(p); + + return NULL; +} static inline void * kmemdup(const void *src, size_t len, gfp_t gfp) -- 2.41.0