mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-29 11:41:21 +03:00
SSSE3 strcpy/stpcpy for x86-64
This patch adds SSSE3 strcpy/stpcpy. I got up to 4X speed up on Core 2 and Core i7. I disabled it on Atom since SSSE3 version is slower for shorter (<64byte) data.
This commit is contained in:
19
ChangeLog
19
ChangeLog
@ -1,3 +1,22 @@
|
||||
2009-06-30 H.J. Lu <hongjiu.lu@intel.com>
|
||||
|
||||
* string/stpncpy.c (STPNCPY): New. Defined if not defined.
|
||||
(__stpncpy): Renamed to ...
|
||||
(STPNCPY): This.
|
||||
(stpncpy): Create alias only if STPNCPY is not defined.
|
||||
* string/strncpy.c (STRNCPY): New. Defined to strncpy if not
|
||||
defined.
|
||||
(strncpy): Renamed to ...
|
||||
(STRNCPY): This.
|
||||
* sysdeps/x86_64/multiarch/Makefile (sysdep_routines): Add
|
||||
stpncpy-c strncpy-c for string.
|
||||
* sysdeps/x86_64/multiarch/stpcpy.S: New file.
|
||||
* sysdeps/x86_64/multiarch/stpncpy-c.c: New file.
|
||||
* sysdeps/x86_64/multiarch/stpncpy.S: New file.
|
||||
* sysdeps/x86_64/multiarch/strcpy.S: New file.
|
||||
* sysdeps/x86_64/multiarch/strncpy-c.c: New file.
|
||||
* sysdeps/x86_64/multiarch/strncpy.S: New file.
|
||||
|
||||
2009-07-02 Ulrich Drepper <drepper@redhat.com>
|
||||
|
||||
* malloc/malloc.c [ATOMIC_FASTBINS] (_int_free): Add full barrier when
|
||||
|
@ -28,17 +28,19 @@
|
||||
# include <sys/types.h>
|
||||
#endif
|
||||
|
||||
#ifndef weak_alias
|
||||
# define __stpncpy stpncpy
|
||||
#ifndef STPNCPY
|
||||
# ifdef weak_alias
|
||||
# define STPNCPY __stpncpy
|
||||
weak_alias (__stpncpy, stpncpy)
|
||||
# else
|
||||
# define STPNCPY stpncpy
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Copy no more than N characters of SRC to DEST, returning the address of
|
||||
the terminating '\0' in DEST, if any, or else DEST + N. */
|
||||
char *
|
||||
__stpncpy (dest, src, n)
|
||||
char *dest;
|
||||
const char *src;
|
||||
size_t n;
|
||||
STPNCPY (char *dest, const char *src, size_t n)
|
||||
{
|
||||
char c;
|
||||
char *s = dest;
|
||||
@ -96,5 +98,4 @@ __stpncpy (dest, src, n)
|
||||
}
|
||||
#ifdef weak_alias
|
||||
libc_hidden_def (__stpncpy)
|
||||
weak_alias (__stpncpy, stpncpy)
|
||||
#endif
|
||||
|
@ -21,11 +21,12 @@
|
||||
|
||||
#undef strncpy
|
||||
|
||||
#ifndef STRNCPY
|
||||
#define STRNCPY strncpy
|
||||
#endif
|
||||
|
||||
char *
|
||||
strncpy (s1, s2, n)
|
||||
char *s1;
|
||||
const char *s2;
|
||||
size_t n;
|
||||
STRNCPY (char *s1, const char *s2, size_t n)
|
||||
{
|
||||
reg_char c;
|
||||
char *s = s1;
|
||||
|
@ -4,5 +4,5 @@ gen-as-const-headers += ifunc-defines.sym
|
||||
endif
|
||||
|
||||
ifeq ($(subdir),string)
|
||||
sysdep_routines += strncmp-c
|
||||
sysdep_routines += stpncpy-c strncpy-c strncmp-c
|
||||
endif
|
||||
|
7
sysdeps/x86_64/multiarch/stpcpy.S
Normal file
7
sysdeps/x86_64/multiarch/stpcpy.S
Normal file
@ -0,0 +1,7 @@
|
||||
#define USE_AS_STPCPY
|
||||
#define STRCPY __stpcpy
|
||||
#include "strcpy.S"
|
||||
|
||||
weak_alias (__stpcpy, stpcpy)
|
||||
libc_hidden_def (__stpcpy)
|
||||
libc_hidden_builtin_def (stpcpy)
|
8
sysdeps/x86_64/multiarch/stpncpy-c.c
Normal file
8
sysdeps/x86_64/multiarch/stpncpy-c.c
Normal file
@ -0,0 +1,8 @@
|
||||
#define STPNCPY __stpncpy_sse2
|
||||
#ifdef SHARED
|
||||
#undef libc_hidden_def
|
||||
#define libc_hidden_def(name) \
|
||||
__hidden_ver1 (__stpncpy_sse2, __GI___stpncpy, __stpncpy_sse2);
|
||||
#endif
|
||||
|
||||
#include "stpncpy.c"
|
6
sysdeps/x86_64/multiarch/stpncpy.S
Normal file
6
sysdeps/x86_64/multiarch/stpncpy.S
Normal file
@ -0,0 +1,6 @@
|
||||
#define STRCPY __stpncpy
|
||||
#define USE_AS_STPCPY
|
||||
#define USE_AS_STRNCPY
|
||||
#include "strcpy.S"
|
||||
|
||||
weak_alias (__stpncpy, stpncpy)
|
1917
sysdeps/x86_64/multiarch/strcpy.S
Normal file
1917
sysdeps/x86_64/multiarch/strcpy.S
Normal file
File diff suppressed because it is too large
Load Diff
8
sysdeps/x86_64/multiarch/strncpy-c.c
Normal file
8
sysdeps/x86_64/multiarch/strncpy-c.c
Normal file
@ -0,0 +1,8 @@
|
||||
#define STRNCPY __strncpy_sse2
|
||||
#ifdef SHARED
|
||||
#undef libc_hidden_builtin_def
|
||||
#define libc_hidden_builtin_def(name) \
|
||||
__hidden_ver1 (__strncpy_sse2, __GI_strncpy, __strncpy_sse2);
|
||||
#endif
|
||||
|
||||
#include "strncpy.c"
|
3
sysdeps/x86_64/multiarch/strncpy.S
Normal file
3
sysdeps/x86_64/multiarch/strncpy.S
Normal file
@ -0,0 +1,3 @@
|
||||
#define STRCPY strncpy
|
||||
#define USE_AS_STRNCPY
|
||||
#include "strcpy.S"
|
Reference in New Issue
Block a user