Browse Source

fix non-align bug in the mem_cpy

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@2239 bbd45198-f89e-11dd-88c7-29a3b14d5316
goprife@gmail.com 12 năm trước cách đây
mục cha
commit
0919b8dab1
1 tập tin đã thay đổi với 8 bổ sung1 xóa
  1. 8 1
      components/dfs/filesystems/elmfat/ff.c

+ 8 - 1
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);