From 0919b8dab184ce36e6ae2db9d6938bdc372edae5 Mon Sep 17 00:00:00 2001 From: "goprife@gmail.com" Date: Mon, 30 Jul 2012 13:39:11 +0000 Subject: [PATCH] fix non-align bug in the mem_cpy git-svn-id: https://rt-thread.googlecode.com/svn/trunk@2239 bbd45198-f89e-11dd-88c7-29a3b14d5316 --- components/dfs/filesystems/elmfat/ff.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/components/dfs/filesystems/elmfat/ff.c b/components/dfs/filesystems/elmfat/ff.c index f6b85c30c..e967bc76d 100644 --- a/components/dfs/filesystems/elmfat/ff.c +++ b/components/dfs/filesystems/elmfat/ff.c @@ -522,7 +522,14 @@ void mem_cpy (void* dst, const void* src, UINT cnt) { BYTE *d = (BYTE*)dst; const BYTE *s = (const BYTE*)src; -#if _WORD_ACCESS == 1 +#if _WORD_ACCESS == 1 + if (((unsigned)d & 0x03)!=0 || ((unsigned)s & 0x03)!=0) + { + while (cnt--) + *d++ = *s++; + return; + } + while (cnt >= sizeof(int)) { *(int*)d = *(int*)s; d += sizeof(int); s += sizeof(int);