diff options
Diffstat (limited to 'arch/mips/boot/compressed/string.c')
-rw-r--r-- | arch/mips/boot/compressed/string.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/arch/mips/boot/compressed/string.c b/arch/mips/boot/compressed/string.c new file mode 100644 index 0000000000..0b593b7092 --- /dev/null +++ b/arch/mips/boot/compressed/string.c @@ -0,0 +1,46 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * arch/mips/boot/compressed/string.c + * + * Very small subset of simple string routines + */ + +#include <linux/compiler_attributes.h> +#include <linux/types.h> + +void *memcpy(void *dest, const void *src, size_t n) +{ + int i; + const char *s = src; + char *d = dest; + + for (i = 0; i < n; i++) + d[i] = s[i]; + return dest; +} + +void *memset(void *s, int c, size_t n) +{ + int i; + char *ss = s; + + for (i = 0; i < n; i++) + ss[i] = c; + return s; +} + +void * __weak memmove(void *dest, const void *src, size_t n) +{ + unsigned int i; + const char *s = src; + char *d = dest; + + if ((uintptr_t)dest < (uintptr_t)src) { + for (i = 0; i < n; i++) + d[i] = s[i]; + } else { + for (i = n; i > 0; i--) + d[i - 1] = s[i - 1]; + } + return dest; +} |