Skip to content

Commit

Permalink
Merge commit 'origin/master' into fedora/master
Browse files Browse the repository at this point in the history
  • Loading branch information
Andreas Schwab committed Jul 22, 2009
2 parents 0457885 + ae612b0 commit 6432246
Show file tree
Hide file tree
Showing 15 changed files with 612 additions and 32 deletions.
41 changes: 41 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,44 @@
2009-07-21 Ulrich Drepper <drepper@redhat.com>

* sysdeps/x86_64/multiarch/strstr.c: Minor cleanups. Remove
unnecesary variables. Comment fixes.

2009-07-20 Ulrich Drepper <drepper@redhat.com>

* sysdeps/x86_64/multiarch/strstr.c [USE_AS_STRCASESTR] (STRSTR_SSE42):
Use NONASCII_CASE information provided by the locale to determine
whether optimized string load function can be used. Minor cleanups.

2009-07-20 H.J. Lu <hongjiu.lu@intel.com>

* string/strcasestr.c (STRCASESTR): New macro.
(__strcasestr): Renamed to ..
(STRCASESTR): ...this.
* string/strstr.c (STRSTR): New macro.
(strstr): Renamed to ..
(STRSTR): ...this.
* sysdeps/x86_64/multiarch/Makefile (sysdep_routines): Add
strstr-c strcasestr-c
(CFLAGS-strstr.c): New.
(CFLAGS-strcasestr.c): Likewise.
* sysdeps/x86_64/multiarch/strcasestr-c.c: New file.
* sysdeps/x86_64/multiarch/strcasestr.c: New file.
* sysdeps/x86_64/multiarch/strstr-c.c: New file.
* sysdeps/x86_64/multiarch/strstr.c: New file.

2009-07-20 Ulrich Drepper <drepper@redhat.com>

* locale/localeinfo.h (LIMAGIC): Update value for LC_CTYPE.
* locale/langinfo.h: Define _NL_CTYPE_NONASCII_CASE.
* locale/C-ctype.c (_nl_C_LC_CTYPE): Add initializer for
_NL_CTYPE_NONASCII_CASE.
* locale/programs/ld-ctype.c (locale_ctype_t): Add nonascii_case
field.
(ctype_finish): Check whether there are any 8-bit characters outside
the range ASCII has or whether the mapping isn't the same as for
ASCII (±0x20). Set nonascii_case appropriately.
(ctype_output): Add output handler for nonascii_case.

2009-07-17 Ulrich Drepper <drepper@redhat.com>

* sysdeps/generic/sysdep.h: Define cfi_personality, cfi_lsda,
Expand Down
6 changes: 4 additions & 2 deletions locale/C-ctype.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 1995-2002, 2003 Free Software Foundation, Inc.
/* Copyright (C) 1995-2002, 2003, 2009 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1995.
Expand Down Expand Up @@ -528,7 +528,7 @@ _nl_C_LC_CTYPE_width attribute_hidden =
};

/* Number of fields with fixed meanings, starting at 0. */
#define NR_FIXED 71
#define NR_FIXED 72
/* Number of class fields, starting at CLASS_OFFSET. */
#define NR_CLASSES 12
/* Number of map fields, starting at MAP_OFFSET. */
Expand Down Expand Up @@ -667,6 +667,8 @@ const struct locale_data _nl_C_LC_CTYPE attribute_hidden =
{ .wstr = NULL },
/* _NL_CTYPE_MAP_TO_NONASCII */
{ .word = 0 },
/* _NL_CTYPE_NONASCII_CASE */
{ .word = 0 },
/* NR_CLASSES wctype_tables */
{ .string = (const char *) _nl_C_LC_CTYPE_class_upper.header },
{ .string = (const char *) _nl_C_LC_CTYPE_class_lower.header },
Expand Down
1 change: 1 addition & 0 deletions locale/langinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ enum
_NL_CTYPE_TRANSLIT_IGNORE_LEN,
_NL_CTYPE_TRANSLIT_IGNORE,
_NL_CTYPE_MAP_TO_NONASCII,
_NL_CTYPE_NONASCII_CASE,
_NL_CTYPE_EXTRA_MAP_1,
_NL_CTYPE_EXTRA_MAP_2,
_NL_CTYPE_EXTRA_MAP_3,
Expand Down
4 changes: 3 additions & 1 deletion locale/localeinfo.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Declarations for internal libc locale interfaces
Copyright (C) 1995-2003, 2005, 2006, 2007, 2008
Copyright (C) 1995-2003, 2005, 2006, 2007, 2008, 2009
Free Software Foundation, Inc.
This file is part of the GNU C Library.
Expand Down Expand Up @@ -35,6 +35,8 @@
#define LIMAGIC(category) \
(category == LC_COLLATE \
? ((unsigned int) (0x20051014 ^ (category))) \
: category == LC_CTYPE \
? ((unsigned int) (0x20090720 ^ (category))) \
: ((unsigned int) (0x20031115 ^ (category))))

/* Two special weight constants for the collation data. */
Expand Down
27 changes: 26 additions & 1 deletion locale/programs/ld-ctype.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 1995-2006, 2007 Free Software Foundation, Inc.
/* Copyright (C) 1995-2006, 2007, 2009 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@gnu.org>, 1995.
Expand Down Expand Up @@ -181,6 +181,7 @@ struct locale_ctype_t
size_t default_missing_lineno;

uint32_t to_nonascii;
uint32_t nonascii_case;

/* The arrays for the binary representation. */
char_class_t *ctype_b;
Expand Down Expand Up @@ -625,6 +626,27 @@ character <SP> not defined in character map")));
else
ctype->class256_collection[space_seq->bytes[0]] |= BIT (tok_print);

/* Check whether all single-byte characters make to their upper/lowercase
equivalent according to the ASCII rules. */
for (cnt = 'A'; cnt <= 'Z'; ++cnt)
{
uint32_t uppval = ctype->map256_collection[0][cnt];
uint32_t lowval = ctype->map256_collection[1][cnt];
uint32_t lowuppval = ctype->map256_collection[0][lowval];
uint32_t lowlowval = ctype->map256_collection[1][lowval];

if (uppval != cnt
|| lowval != cnt + 0x20
|| lowuppval != cnt
|| lowlowval != cnt + 0x20)
ctype->nonascii_case = 1;
}
for (cnt = 0; cnt < 256; ++cnt)
if (cnt < 'A' || (cnt > 'Z' && cnt < 'a') || cnt > 'z')
if (ctype->map256_collection[0][cnt] != cnt
|| ctype->map256_collection[1][cnt] != cnt)
ctype->nonascii_case = 1;

/* Now that the tests are done make sure the name array contains all
characters which are handled in the WIDTH section of the
character set definition file. */
Expand Down Expand Up @@ -1045,6 +1067,9 @@ ctype_output (struct localedef_t *locale, const struct charmap_t *charmap,
CTYPE_DATA (_NL_CTYPE_MAP_TO_NONASCII,
&ctype->to_nonascii, sizeof (uint32_t));

CTYPE_DATA (_NL_CTYPE_NONASCII_CASE,
&ctype->nonascii_case, sizeof (uint32_t));

case _NL_ITEM_INDEX (_NL_CTYPE_INDIGITS_MB_LEN):
iov[2 + elem + offset].iov_base = alloca (sizeof (uint32_t));
iov[2 + elem + offset].iov_len = sizeof (uint32_t);
Expand Down
6 changes: 6 additions & 0 deletions nptl/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
2009-07-20 Ulrich Drepper <drepper@redhat.com>

* sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S: Minor
optimizations of last changes.
* sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S: Likewise.

2009-07-19 Ulrich Drepper <drepper@redhat.com>

* sysdeps/unix/sysv/linux/x86_64/lowlevellock.h: Define
Expand Down
8 changes: 3 additions & 5 deletions nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S
Original file line number Diff line number Diff line change
Expand Up @@ -160,16 +160,14 @@ __pthread_cond_timedwait:
movq 8(%rsp), %rdi

movq %r13, %r10
movl $FUTEX_WAIT_BITSET, %esi
cmpq $-1, dep_mutex(%rdi)
movl $FUTEX_WAIT_BITSET, %eax
movl $(FUTEX_WAIT_BITSET|FUTEX_PRIVATE_FLAG), %esi
cmove %eax, %esi
je 60f

movq dep_mutex(%rdi), %r8
/* Requeue to a PI mutex if the PI bit is set. */
testl $PI_BIT, MUTEX_KIND(%r8)
je 60f
je 61f

movl $(FUTEX_WAIT_REQUEUE_PI|FUTEX_PRIVATE_FLAG), %esi
xorl %eax, %eax
Expand All @@ -191,10 +189,10 @@ __pthread_cond_timedwait:
cmpq $-4095, %rax
jnae 62f

movl $(FUTEX_WAIT_BITSET|FUTEX_PRIVATE_FLAG), %esi
subq $cond_futex, %rdi
#endif

61: movl $(FUTEX_WAIT_BITSET|FUTEX_PRIVATE_FLAG), %esi
60: xorl %r15d, %r15d
xorl %eax, %eax
/* The following only works like this because we only support
Expand Down
31 changes: 13 additions & 18 deletions nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S
Original file line number Diff line number Diff line change
Expand Up @@ -128,28 +128,15 @@ __pthread_cond_wait:
movq 8(%rsp), %rdi
xorq %r10, %r10
movq %r12, %rdx
// XXX reverse + lea
addq $cond_futex, %rdi
cmpq $-1, dep_mutex-cond_futex(%rdi)
#ifdef __ASSUME_PRIVATE_FUTEX
movl $FUTEX_WAIT, %eax
movl $(FUTEX_WAIT|FUTEX_PRIVATE_FLAG), %esi
cmove %eax, %esi
#else
movl $0, %eax
movl %fs:PRIVATE_FUTEX, %esi
cmove %eax, %esi
# if FUTEX_WAIT != 0
# error "cc destroyed by following orl"
orl $FUTEX_WAIT, %esi
# endif
#endif
cmpq $-1, dep_mutex(%rdi)
leaq cond_futex(%rdi), %rdi
movl $FUTEX_WAIT, %esi
je 60f

movq dep_mutex-cond_futex(%rdi), %r8
/* Requeue to a PI mutex if the PI bit is set. */
testl $PI_BIT, MUTEX_KIND(%r8)
je 60f
je 61f

movl $(FUTEX_WAIT_REQUEUE_PI|FUTEX_PRIVATE_FLAG), %esi
movl $SYS_futex, %eax
Expand All @@ -162,9 +149,17 @@ __pthread_cond_wait:
cmpq $-4095, %rax
jnae 62f

movl $(FUTEX_WAIT|FUTEX_PRIVATE_FLAG), %esi
# ifndef __ASSUME_PRIVATE_FUTEX
movl $FUTEX_WAIT, %esi
# endif
#endif

61:
#ifdef __ASSUME_PRIVATE_FUTEX
movl $(FUTEX_WAIT|FUTEX_PRIVATE_FLAG), %esi
#else
orl %fs:PRIVATE_FUTEX, %esi
#endif
60: xorl %r13d, %r13d
movl $SYS_futex, %eax
syscall
Expand Down
10 changes: 8 additions & 2 deletions string/strcasestr.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* Return the offset of one string within another.
Copyright (C) 1994, 1996-2000, 2004, 2008 Free Software Foundation, Inc.
Copyright (C) 1994, 1996-2000, 2004, 2008, 2009
Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
Expand Down Expand Up @@ -52,11 +53,16 @@
#undef strcasestr
#undef __strcasestr

#ifndef STRCASESTR
#define STRCASESTR __strcasestr
#endif


/* Find the first occurrence of NEEDLE in HAYSTACK, using
case-insensitive comparison. This function gives unspecified
results in multibyte locales. */
char *
__strcasestr (const char *haystack_start, const char *needle_start)
STRCASESTR (const char *haystack_start, const char *needle_start)
{
const char *haystack = haystack_start;
const char *needle = needle_start;
Expand Down
9 changes: 7 additions & 2 deletions string/strstr.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* Return the offset of one string within another.
Copyright (C) 1994,1996,1997,2000,2001,2003,2008 Free Software Foundation, Inc.
Copyright (C) 1994,1996,1997,2000,2001,2003,2008,2009
Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
Expand Down Expand Up @@ -40,11 +41,15 @@

#undef strstr

#ifndef STRSTR
#define STRSTR strstr
#endif

/* Return the first occurrence of NEEDLE in HAYSTACK. Return HAYSTACK
if NEEDLE is empty, otherwise NULL if NEEDLE is not found in
HAYSTACK. */
char *
strstr (const char *haystack_start, const char *needle_start)
STRSTR (const char *haystack_start, const char *needle_start)
{
const char *haystack = haystack_start;
const char *needle = needle_start;
Expand Down
4 changes: 3 additions & 1 deletion sysdeps/x86_64/multiarch/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ endif
ifeq ($(subdir),string)
sysdep_routines += stpncpy-c strncpy-c strncmp-c
ifeq (yes,$(config-cflags-sse4))
sysdep_routines += strcspn-c strpbrk-c strspn-c
sysdep_routines += strcspn-c strpbrk-c strspn-c strstr-c strcasestr-c
CFLAGS-strcspn-c.c += -msse4
CFLAGS-strpbrk-c.c += -msse4
CFLAGS-strspn-c.c += -msse4
CFLAGS-strstr.c += -msse4
CFLAGS-strcasestr.c += -msse4
endif
endif
18 changes: 18 additions & 0 deletions sysdeps/x86_64/multiarch/strcasestr-c.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include "init-arch.h"

#define STRCASESTR __strcasestr_sse2
#undef libc_hidden_builtin_def
#define libc_hidden_builtin_def(name) \
__hidden_ver1 (__strcasestr_sse2, __GI_strcasestr, __strcasestr_sse2);

#include "string/strcasestr.c"

extern char *__strcasestr_sse42 (const char *, const char *);

#if 1
libc_ifunc (__strcasestr,
HAS_SSE4_2 ? __strcasestr_sse42 : __strcasestr_sse2);
#else
libc_ifunc (__strcasestr,
0 ? __strcasestr_sse42 : __strcasestr_sse2);
#endif
3 changes: 3 additions & 0 deletions sysdeps/x86_64/multiarch/strcasestr.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#define USE_AS_STRCASESTR
#define STRSTR_SSE42 __strcasestr_sse42
#include "strstr.c"
12 changes: 12 additions & 0 deletions sysdeps/x86_64/multiarch/strstr-c.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include "init-arch.h"

#define STRSTR __strstr_sse2
#undef libc_hidden_builtin_def
#define libc_hidden_builtin_def(name) \
__hidden_ver1 (__strstr_sse2, __GI_strstr, __strstr_sse2);

#include "string/strstr.c"

extern char *__strstr_sse42 (const char *, const char *);

libc_ifunc (strstr, HAS_SSE4_2 ? __strstr_sse42 : __strstr_sse2);
Loading

0 comments on commit 6432246

Please sign in to comment.