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/arm/memcpy.S | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'firmware/asm/arm') diff --git a/firmware/asm/arm/memcpy.S b/firmware/asm/arm/memcpy.S index 2a55fb5656..83d43293e6 100644 --- a/firmware/asm/arm/memcpy.S +++ b/firmware/asm/arm/memcpy.S @@ -36,17 +36,25 @@ #endif /* Prototype: void *memcpy(void *dest, const void *src, size_t n); */ +/* Prototype: void *mempcpy(void *dest, const void *src, size_t n); */ .section .icode,"ax",%progbits .align 2 .global memcpy .type memcpy,%function + .global mempcpy + .type mempcpy,%function + +mempcpy: + add r3, r0, r2 + stmfd sp!, {r3, r4, lr} + b 0f memcpy: stmfd sp!, {r0, r4, lr} - subs r2, r2, #4 +0: subs r2, r2, #4 blt 8f ands ip, r0, #3 bne 9f -- cgit v1.2.3