diff options
| author | Ali Al-Asadi <alasadi56@gmail.com> | 2017-09-16 18:03:39 +0200 |
|---|---|---|
| committer | Ali Al-Asadi <alasadi56@gmail.com> | 2017-09-16 18:03:57 +0200 |
| commit | 6d7a43ef2973fd127bf910a521d4808661fe7174 (patch) | |
| tree | 0d60991bc8253ef8f3cd8dd7db7f3f6b6607a39c /lib/string.c | |
| parent | 3d01b8790e7e69fb347bacdaafb85f7f1896067b (diff) | |
| parent | 870ce5261ecd42ac7035ad5e345e14ce0c7837fe (diff) | |
msm8960: get all the needed changes for kernelo8.0
Merge branch 'lineage-15.0' of https://github.com/tathanhlam66/android_kernel_htc_msm8960 into o8.0
Change-Id: Ib0698d0a99afbfe73e1bfccddcfb29df5d085045
Diffstat (limited to 'lib/string.c')
| -rw-r--r-- | lib/string.c | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/lib/string.c b/lib/string.c index 43d0781daf4..81a0ae6558e 100644 --- a/lib/string.c +++ b/lib/string.c @@ -26,6 +26,7 @@ #include <linux/export.h> #include <linux/bug.h> #include <linux/errno.h> +#include <linux/memcopy.h> #ifndef __HAVE_ARCH_STRNICMP /** @@ -614,11 +615,11 @@ EXPORT_SYMBOL(memzero_explicit); */ void *memcpy(void *dest, const void *src, size_t count) { - char *tmp = dest; - const char *s = src; + unsigned long dstp = (unsigned long)dest; + unsigned long srcp = (unsigned long)src; - while (count--) - *tmp++ = *s++; + /* Copy from the beginning to the end */ + mem_copy_fwd(dstp, srcp, count); return dest; } EXPORT_SYMBOL(memcpy); @@ -635,21 +636,15 @@ EXPORT_SYMBOL(memcpy); */ void *memmove(void *dest, const void *src, size_t count) { - char *tmp; - const char *s; + unsigned long dstp = (unsigned long)dest; + unsigned long srcp = (unsigned long)src; - if (dest <= src) { - tmp = dest; - s = src; - while (count--) - *tmp++ = *s++; + if (dest - src >= count) { + /* Copy from the beginning to the end */ + mem_copy_fwd(dstp, srcp, count); } else { - tmp = dest; - tmp += count; - s = src; - s += count; - while (count--) - *--tmp = *--s; + /* Copy from the end to the beginning */ + mem_copy_bwd(dstp, srcp, count); } return dest; } |
