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/m68k/memcpy.S | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'firmware/asm/m68k') diff --git a/firmware/asm/m68k/memcpy.S b/firmware/asm/m68k/memcpy.S index 9762e31e02..a88ac3d091 100644 --- a/firmware/asm/m68k/memcpy.S +++ b/firmware/asm/m68k/memcpy.S @@ -27,6 +27,8 @@ .global memcpy .global __memcpy_fwd_entry .type memcpy,@function + .global mempcpy + .type mempcpy,@function /* Copies bytes of data in memory from to * This version is optimized for speed @@ -53,6 +55,14 @@ * long+3) it writes longwords only. Same goes for word aligned destinations * if FULLSPEED is undefined. */ +mempcpy: + move.l (4,%sp),%a1 /* Destination */ + move.l (8,%sp),%a0 /* Source */ + move.l (12,%sp),%d1 /* Length */ + + add.l %d1,(4,%sp) /* retval=Destination + Length */ + bra.b __memcpy_fwd_entry + memcpy: move.l (4,%sp),%a1 /* Destination */ move.l (8,%sp),%a0 /* Source */ -- cgit v1.2.3