Skip to content

Commit

Permalink
Add SSE4.2 support for strcmp and strncmp on x86-64.
Browse files Browse the repository at this point in the history
  • Loading branch information
H.J. Lu authored and Ulrich Drepper committed Jun 23, 2009
1 parent 9618c7c commit 772f4e6
Show file tree
Hide file tree
Showing 7 changed files with 1,714 additions and 5 deletions.
12 changes: 12 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
2009-06-22 H.J. Lu <hongjiu.lu@intel.com>

* string/strncmp.c (STRNCMP): New. Defined to strncmp if not
defined.
(strncmp): Renamed to STRNCMP.
* sysdeps/x86_64/multiarch/Makefile (sysdep_routines): Add
strncmp-c for string.
* sysdeps/x86_64/multiarch/init-arch.h (HAS_SSE4_2): Define.
* sysdeps/x86_64/multiarch/strcmp.S: New file.
* sysdeps/x86_64/multiarch/strncmp.S: New file.
* sysdeps/x86_64/multiarch/strncmp-c.c: New file.

2009-06-19 H.J. Lu <hongjiu.lu@intel.com>

* elf/Makefile (distribute): Add ifuncmain1staticpie.c,
Expand Down
12 changes: 7 additions & 5 deletions string/strncmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,16 @@

#undef strncmp

#ifndef STRNCMP
#define STRNCMP strncmp
#endif

/* Compare no more than N characters of S1 and S2,
returning less than, equal to or greater than zero
if S1 is lexicographically less than, equal to or
greater than S2. */
int
strncmp (s1, s2, n)
const char *s1;
const char *s2;
size_t n;
STRNCMP (const char *s1, const char *s2, size_t n)
{
unsigned reg_char c1 = '\0';
unsigned reg_char c2 = '\0';
Expand Down Expand Up @@ -70,4 +71,5 @@ strncmp (s1, s2, n)

return c1 - c2;
}
libc_hidden_builtin_def (strncmp)

libc_hidden_builtin_def (STRNCMP)
4 changes: 4 additions & 0 deletions sysdeps/x86_64/multiarch/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@ ifeq ($(subdir),csu)
aux += init-arch
gen-as-const-headers += ifunc-defines.sym
endif

ifeq ($(subdir),string)
sysdep_routines += strncmp-c
endif
3 changes: 3 additions & 0 deletions sysdeps/x86_64/multiarch/init-arch.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,6 @@ extern void __init_cpu_features (void) attribute_hidden;

#define HAS_POPCOUNT \
((__cpu_features.cpuid[COMMON_CPUID_INDEX_1].ecx & (1 << 23)) != 0)

#define HAS_SSE4_2 \
((__cpu_features.cpuid[COMMON_CPUID_INDEX_1].ecx & (1 << 20)) != 0)
Loading

0 comments on commit 772f4e6

Please sign in to comment.