|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen staging] lib: move memchr_inv()
commit 47cb18e069695f889577fc3651227541820f502b
Author: Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Thu Apr 22 14:45:33 2021 +0200
Commit: Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Thu Apr 22 14:45:33 2021 +0200
lib: move memchr_inv()
Allow the function to be individually linkable, discardable, and
overridable.
Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
Acked-by: Julien Grall <jgrall@xxxxxxxxxx>
---
xen/common/string.c | 20 --------------------
xen/lib/Makefile | 1 +
xen/lib/memchr_inv.c | 35 +++++++++++++++++++++++++++++++++++
3 files changed, 36 insertions(+), 20 deletions(-)
diff --git a/xen/common/string.c b/xen/common/string.c
index ba282637f1..eae5e2a314 100644
--- a/xen/common/string.c
+++ b/xen/common/string.c
@@ -311,26 +311,6 @@ char *(strstr)(const char *s1, const char *s2)
}
#endif
-/**
- * memchr_inv - Find an unmatching character in an area of memory.
- * @s: The memory area
- * @c: The byte that is expected
- * @n: The size of the area.
- *
- * returns the address of the first occurrence of a character other than @c,
- * or %NULL if the whole buffer contains just @c.
- */
-void *memchr_inv(const void *s, int c, size_t n)
-{
- const unsigned char *p = s;
-
- while (n--)
- if ((unsigned char)c != *p++)
- return (void *)(p - 1);
-
- return NULL;
-}
-
/*
* Local variables:
* mode: C
diff --git a/xen/lib/Makefile b/xen/lib/Makefile
index acdd0a4a12..ce61fbe3cd 100644
--- a/xen/lib/Makefile
+++ b/xen/lib/Makefile
@@ -5,6 +5,7 @@ lib-y += ctors.o
lib-y += ctype.o
lib-y += list-sort.o
lib-y += memchr.o
+lib-y += memchr_inv.o
lib-y += memcmp.o
lib-y += memcpy.o
lib-y += memmove.o
diff --git a/xen/lib/memchr_inv.c b/xen/lib/memchr_inv.c
new file mode 100644
index 0000000000..1bf6cb6ee0
--- /dev/null
+++ b/xen/lib/memchr_inv.c
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 1991, 1992 Linus Torvalds
+ */
+
+#include <xen/string.h>
+
+/**
+ * memchr_inv - Find an unmatching character in an area of memory.
+ * @s: The memory area
+ * @c: The byte that is expected
+ * @n: The size of the area.
+ *
+ * returns the address of the first occurrence of a character other than @c,
+ * or %NULL if the whole buffer contains just @c.
+ */
+void *memchr_inv(const void *s, int c, size_t n)
+{
+ const unsigned char *p = s;
+
+ while (n--)
+ if ((unsigned char)c != *p++)
+ return (void *)(p - 1);
+
+ return NULL;
+}
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 8
+ * tab-width: 8
+ * indent-tabs-mode: t
+ * End:
+ */
--
generated by git-patchbot for /home/xen/git/xen.git#staging
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |