summaryrefslogtreecommitdiff
path: root/lib_generic
diff options
context:
space:
mode:
authorMinkyu Kang <mk7.kang@samsung.com>2009-11-10 08:44:30 +0900
committerMinkyu Kang <mk7.kang@samsung.com>2009-11-10 08:44:30 +0900
commitb6d8992cbbe5f04c11f7e6e09c09ae1a031d8720 (patch)
tree38d607f78f33bcd41d8da448f4da7d5c220b4f93 /lib_generic
parentf9000d975b5f2550defd5fe5b57392a72fc77201 (diff)
parentb91b8f74fe9ded18344c3d03080a4abc07254502 (diff)
downloadu-boot-imx-b6d8992cbbe5f04c11f7e6e09c09ae1a031d8720.zip
u-boot-imx-b6d8992cbbe5f04c11f7e6e09c09ae1a031d8720.tar.gz
u-boot-imx-b6d8992cbbe5f04c11f7e6e09c09ae1a031d8720.tar.bz2
Merge branch 'master' of git://git.denx.de/u-boot-arm
Diffstat (limited to 'lib_generic')
-rw-r--r--lib_generic/string.c41
1 files changed, 34 insertions, 7 deletions
diff --git a/lib_generic/string.c b/lib_generic/string.c
index 181eda6..b375b81 100644
--- a/lib_generic/string.c
+++ b/lib_generic/string.c
@@ -403,10 +403,26 @@ char *strswab(const char *s)
*/
void * memset(void * s,int c,size_t count)
{
- char *xs = (char *) s;
-
+ unsigned long *sl = (unsigned long *) s;
+ unsigned long cl = 0;
+ char *s8;
+ int i;
+
+ /* do it one word at a time (32 bits or 64 bits) while possible */
+ if ( ((ulong)s & (sizeof(*sl) - 1)) == 0) {
+ for (i = 0; i < sizeof(*sl); i++) {
+ cl <<= 8;
+ cl |= c & 0xff;
+ }
+ while (count >= sizeof(*sl)) {
+ *sl++ = cl;
+ count -= sizeof(*sl);
+ }
+ }
+ /* fill 8 bits at a time */
+ s8 = (char *)sl;
while (count--)
- *xs++ = c;
+ *s8++ = c;
return s;
}
@@ -446,12 +462,23 @@ char * bcopy(const char * src, char * dest, int count)
* You should not use this function to access IO space, use memcpy_toio()
* or memcpy_fromio() instead.
*/
-void * memcpy(void * dest,const void *src,size_t count)
+void * memcpy(void *dest, const void *src, size_t count)
{
- char *tmp = (char *) dest, *s = (char *) src;
-
+ unsigned long *dl = (unsigned long *)dest, *sl = (unsigned long *)src;
+ char *d8, *s8;
+
+ /* while all data is aligned (common case), copy a word at a time */
+ if ( (((ulong)dest | (ulong)src) & (sizeof(*dl) - 1)) == 0) {
+ while (count >= sizeof(*dl)) {
+ *dl++ = *sl++;
+ count -= sizeof(*dl);
+ }
+ }
+ /* copy the reset one byte at a time */
+ d8 = (char *)dl;
+ s8 = (char *)sl;
while (count--)
- *tmp++ = *s++;
+ *d8++ = *s8++;
return dest;
}