diff options
Diffstat (limited to 'arch/s390/boot/compressed/misc.c')
-rw-r--r-- | arch/s390/boot/compressed/misc.c | 45 |
1 files changed, 24 insertions, 21 deletions
diff --git a/arch/s390/boot/compressed/misc.c b/arch/s390/boot/compressed/misc.c index 465eca756feb..c4c6a1cf221b 100644 --- a/arch/s390/boot/compressed/misc.c +++ b/arch/s390/boot/compressed/misc.c | |||
@@ -71,34 +71,37 @@ void *memset(void *s, int c, size_t n) | |||
71 | { | 71 | { |
72 | char *xs; | 72 | char *xs; |
73 | 73 | ||
74 | if (c == 0) | 74 | xs = s; |
75 | return __builtin_memset(s, 0, n); | 75 | while (n--) |
76 | 76 | *xs++ = c; | |
77 | xs = (char *) s; | ||
78 | if (n > 0) | ||
79 | do { | ||
80 | *xs++ = c; | ||
81 | } while (--n > 0); | ||
82 | return s; | 77 | return s; |
83 | } | 78 | } |
84 | 79 | ||
85 | void *memcpy(void *__dest, __const void *__src, size_t __n) | 80 | void *memcpy(void *dest, const void *src, size_t n) |
86 | { | 81 | { |
87 | return __builtin_memcpy(__dest, __src, __n); | 82 | const char *s = src; |
83 | char *d = dest; | ||
84 | |||
85 | while (n--) | ||
86 | *d++ = *s++; | ||
87 | return dest; | ||
88 | } | 88 | } |
89 | 89 | ||
90 | void *memmove(void *__dest, __const void *__src, size_t __n) | 90 | void *memmove(void *dest, const void *src, size_t n) |
91 | { | 91 | { |
92 | char *d; | 92 | const char *s = src; |
93 | const char *s; | 93 | char *d = dest; |
94 | 94 | ||
95 | if (__dest <= __src) | 95 | if (d <= s) { |
96 | return __builtin_memcpy(__dest, __src, __n); | 96 | while (n--) |
97 | d = __dest + __n; | 97 | *d++ = *s++; |
98 | s = __src + __n; | 98 | } else { |
99 | while (__n--) | 99 | d += n; |
100 | *--d = *--s; | 100 | s += n; |
101 | return __dest; | 101 | while (n--) |
102 | *--d = *--s; | ||
103 | } | ||
104 | return dest; | ||
102 | } | 105 | } |
103 | 106 | ||
104 | static void error(char *x) | 107 | static void error(char *x) |