lib: move memset()
authorJan Beulich <jbeulich@suse.com>
Thu, 22 Apr 2021 12:42:31 +0000 (14:42 +0200)
committerJan Beulich <jbeulich@suse.com>
Thu, 22 Apr 2021 12:42:31 +0000 (14:42 +0200)
By moving the function into an archive, x86 doesn't need to announce
anymore that is has its own implementation - symbol resolution by the
linker will now guarantee that the generic function remains unused, and
the forwarding to the compiler built-in gets done by the common header
anyway.

Allow the function to be individually linkable, discardable, and
overridable.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Julien Grall <jgrall@amazon.com>
xen/common/string.c
xen/include/asm-x86/string.h
xen/lib/Makefile
xen/lib/memset.c [new file with mode: 0644]

index af3d96ad0fa3a07fd4fc5ae48a2e859bbc080bcc..3c83736d6bb60b740134c4348dd8d3e22dec8af9 100644 (file)
@@ -311,26 +311,6 @@ char *(strstr)(const char *s1, const char *s2)
 }
 #endif
 
-#ifndef __HAVE_ARCH_MEMSET
-/**
- * memset - Fill a region of memory with the given value
- * @s: Pointer to the start of the area.
- * @c: The byte to fill the area with
- * @count: The size of the area.
- *
- * Do not use memset() to access IO space, use memset_io() instead.
- */
-void *(memset)(void *s, int c, size_t count)
-{
-       char *xs = (char *) s;
-
-       while (count--)
-               *xs++ = c;
-
-       return s;
-}
-#endif
-
 #ifndef __HAVE_ARCH_MEMCPY
 /**
  * memcpy - Copy one area of memory to another
index 4f1e1d4daf836eb90c21a9e3e5d293834ebff389..3102d91f132ff46b63c578d70ce21979df1ebf83 100644 (file)
@@ -7,9 +7,6 @@
 #define __HAVE_ARCH_MEMMOVE
 #define memmove(d, s, n) __builtin_memmove(d, s, n)
 
-#define __HAVE_ARCH_MEMSET
-#define memset(s, c, n) __builtin_memset(s, c, n)
-
 #endif /* __X86_STRING_H__ */
 /*
  * Local variables:
index a5dc1442a422f4f7f9675537955917096f61a6b9..98e5747ca7c4691cfcc99e54c07f43d0b050ef90 100644 (file)
@@ -4,6 +4,7 @@ lib-y += bsearch.o
 lib-y += ctors.o
 lib-y += ctype.o
 lib-y += list-sort.o
+lib-y += memset.o
 lib-y += muldiv64.o
 lib-y += parse-size.o
 lib-y += rbtree.o
diff --git a/xen/lib/memset.c b/xen/lib/memset.c
new file mode 100644 (file)
index 0000000..e86afaf
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ *  Copyright (C) 1991, 1992  Linus Torvalds
+ */
+
+#include <xen/string.h>
+
+/**
+ * memset - Fill a region of memory with the given value
+ * @s: Pointer to the start of the area.
+ * @c: The byte to fill the area with
+ * @count: The size of the area.
+ *
+ * Do not use memset() to access IO space, use memset_io() instead.
+ */
+void *(memset)(void *s, int c, size_t count)
+{
+       char *xs = (char *) s;
+
+       while (count--)
+               *xs++ = c;
+
+       return s;
+}
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 8
+ * tab-width: 8
+ * indent-tabs-mode: t
+ * End:
+ */