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/include/string-extra.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'firmware/include') diff --git a/firmware/include/string-extra.h b/firmware/include/string-extra.h index bae250d7c9..6a9e0c77be 100644 --- a/firmware/include/string-extra.h +++ b/firmware/include/string-extra.h @@ -18,8 +18,8 @@ * KIND, either express or implied. * ****************************************************************************/ - - +#ifndef STRING_EXTRA_H +#define STRING_EXTRA_H #include #include "strlcpy.h" #include "strlcat.h" @@ -27,3 +27,11 @@ #include "strcasestr.h" #include "strtok_r.h" #include "memset16.h" + +#if defined(WIN32) || defined(APPLICATION) +#ifndef mempcpy +#define mempcpy __builtin_mempcpy +#endif +#endif + +#endif /* STRING_EXTRA_H */ -- cgit v1.2.3