From 77b3625763ae4d5aa6aaa9d44fbc1bfec6b29335 Mon Sep 17 00:00:00 2001 From: Michael Sevakis Date: Wed, 6 Aug 2014 04:26:52 -0400 Subject: Add mempcpy implementation A GNU extension that returns dst + size instead of dst. It's a nice shortcut when copying strings with a known size or back-to-back blocks and you have to do it often. May of course be called directly or alternately through __builtin_mempcpy in some compiler versions. For ASM on native targets, it is implemented as an alternate entrypoint to memcpy which adds minimal code and overhead. Change-Id: I4cbb3483f6df3c1007247fe0a95fd7078737462b --- firmware/asm/sh/memcpy.S | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'firmware/asm/sh') diff --git a/firmware/asm/sh/memcpy.S b/firmware/asm/sh/memcpy.S index 59c5801ac0..3d623c48cd 100644 --- a/firmware/asm/sh/memcpy.S +++ b/firmware/asm/sh/memcpy.S @@ -24,8 +24,10 @@ .align 2 .global _memcpy + .global _mempcpy .global ___memcpy_fwd_entry .type _memcpy,@function + .type _mempcpy,@function /* Copies bytes of data in memory from to * This version is optimized for speed @@ -51,6 +53,10 @@ * The instruction order is devised in a way to utilize the pipelining * of the SH1 to the max. The routine also tries to utilize fast page mode. */ +_mempcpy: + mov r4,r7 /* store dest + length for returning */ + bra ___memcpy_fwd_entry + add r6,r7 _memcpy: mov r4,r7 /* store dest for returning */ @@ -217,3 +223,5 @@ ___memcpy_fwd_entry: mov r7,r0 /* return dest start address */ .end: .size _memcpy,.end-_memcpy + .size _mempcpy,.end-_mempcpy + -- cgit v1.2.3