[Cbe-oss-dev] [PATCH 10/23]MARS/base: simple mem func

Yuji Mano yuji.mano at am.sony.com
Sat Mar 14 12:18:35 EST 2009


From: Kazunori Asayama <asayama at sm.sony.co.jp>

Reduce code size of MPU kernel_mem* functions

This patch reduces code size of kernel_mem* functions in the MARS
kernel implementation by using vector operations. It assumes 16-bytes
boundary alignment and size.

Signed-off-by: Kazunori Asayama <asayama at sm.sony.co.jp>
Signed-off-by: Yuji Mano <yuji.mano at am.sony.com>
---
 base/src/mpu/kernel/kernel.c |   20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

Index: b/base/src/mpu/kernel/kernel.c
===================================================================
--- a/base/src/mpu/kernel/kernel.c	2009-02-25 11:10:38.000000000 +0900
+++ b/base/src/mpu/kernel/kernel.c	2009-02-25 11:48:17.000000000 +0900
@@ -77,12 +77,12 @@ typedef void (*module_entry)(
 
 static int kernel_memcmp(const void *s1, const void *s2, int size)
 {
-	const unsigned char *ptr_1 = (const unsigned char *)s1;
-	const unsigned char *ptr_2 = (const unsigned char *)s2;
-	const unsigned char *ptr_e = ptr_1 + size;
+	__vector const int *vptr_1 = (__vector const int *)s1;
+	__vector const int *vptr_2 = (__vector const int *)s2;
+	__vector const int *vptr_e = (__vector const int *)(s1 + size);
 
-	while (ptr_1 < ptr_e)
-		if (*ptr_1++ != *ptr_2++)
+	while (vptr_1 < vptr_e)
+		if (!(*vptr_1++ == *vptr_2++))
 			return 1;
 
 	return 0;
@@ -90,12 +90,12 @@ static int kernel_memcmp(const void *s1,
 
 static void kernel_memcpy(void *dst, const void *src, int size)
 {
-	unsigned char *ptr_1 = (unsigned char *)dst;
-	const unsigned char *ptr_2 = (const unsigned char *)src;
-	const unsigned char *ptr_e = ptr_1 + size;
+	__vector const int *vptr_src = (__vector const int *)src;
+	__vector int *vptr_dst = (__vector int *)dst;
+	__vector int *vptr_end = (__vector int *)(dst + size);
 
-	while (ptr_1 < ptr_e)
-		*ptr_1++ = *ptr_2++;
+	while (vptr_dst < vptr_end)
+		*vptr_dst++ = *vptr_src++;
 }
 
 static uint32_t get_ticks(void)






More information about the cbe-oss-dev mailing list