Skip to content

Commit

Permalink
Improve performance of mempcpy by inlining and using memcpy. Enable
Browse files Browse the repository at this point in the history
this for all targets except sparc which has an optimized mempcpy
implementation.
  • Loading branch information
Wilco Dijkstra committed Aug 5, 2015
1 parent f29ac72 commit 05a910f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
2015-08-05 Wilco Dijkstra <wdijkstr@arm.com>

* string/string.h: (mempcpy): Redirect to __mempcpy_inline.
(__mempcpy): Likewise. (__mempcpy_inline): New inline function.
* sysdeps/sparc/bits/string.h: (_HAVE_STRING_ARCH_mempcpy): Define.

2015-08-05 Wilco Dijkstra <wdijkstr@arm.com>

* string/memccpy.c (memccpy):
Expand Down
19 changes: 19 additions & 0 deletions string/string.h
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,25 @@ extern char *basename (const char *__filename) __THROW __nonnull ((1));
# endif
#endif

#if defined __USE_GNU && defined __OPTIMIZE__ \
&& defined __extern_always_inline && __GNUC_PREREQ (3,2)
# if !defined _FORCE_INLINES && !defined _HAVE_STRING_ARCH_mempcpy

#undef mempcpy
#undef __mempcpy
#define mempcpy(dest, src, n) __mempcpy_inline (dest, src, n)
#define __mempcpy(dest, src, n) __mempcpy_inline (dest, src, n)

__extern_always_inline void *
__mempcpy_inline (void *__restrict __dest,
const void *__restrict __src, size_t __n)
{
return (char *) memcpy (__dest, __src, __n) + __n;
}

# endif
#endif

__END_DECLS

#endif /* string.h */
3 changes: 3 additions & 0 deletions sysdeps/sparc/bits/string.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@
/* sparc32 and sparc64 strchr(x, '\0') perform better than
__rawmemchr(x, '\0'). */
#define _HAVE_STRING_ARCH_strchr 1

/* Don't inline mempcpy into memcpy as sparc has an optimized mempcpy. */
#define _HAVE_STRING_ARCH_mempcpy 1

0 comments on commit 05a910f

Please sign in to comment.