aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2004-10-19 21:21:42 +0000
committerUlrich Drepper <drepper@redhat.com>2004-10-19 21:21:42 +0000
commit708c687a6f64bf7ea5dec46b28073fc8eacec1ca (patch)
tree02416968a6c670f1c8ada16e96acc5a12839882f
parent653aeda54916d28b010c1bb2240c962b9d01b6ad (diff)
downloadglibc-708c687a6f64bf7ea5dec46b28073fc8eacec1ca.tar
glibc-708c687a6f64bf7ea5dec46b28073fc8eacec1ca.tar.gz
glibc-708c687a6f64bf7ea5dec46b28073fc8eacec1ca.tar.bz2
glibc-708c687a6f64bf7ea5dec46b28073fc8eacec1ca.zip
Update.
2004-10-18 Jakub Jelinek <jakub@redhat.com> * sysdeps/generic/strcpy_chk.c (__strcpy_chk): Speed up by checking destlen only every 4 bytes.
-rw-r--r--ChangeLog5
-rw-r--r--sysdeps/generic/strcpy_chk.c30
2 files changed, 31 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 4594957ab9..f57da5f16e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2004-10-18 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/generic/strcpy_chk.c (__strcpy_chk): Speed up by checking
+ destlen only every 4 bytes.
+
2004-10-19 Ulrich Drepper <drepper@redhat.com>
* nss/getent.c (hosts_keys): Let inet_pton decide whether the
diff --git a/sysdeps/generic/strcpy_chk.c b/sysdeps/generic/strcpy_chk.c
index 5c1ae44cd0..a4d909feda 100644
--- a/sysdeps/generic/strcpy_chk.c
+++ b/sysdeps/generic/strcpy_chk.c
@@ -31,14 +31,36 @@ __strcpy_chk (dest, src, destlen)
{
reg_char c;
char *s = (char *) src;
- const ptrdiff_t off = dest - s - 1;
+ const ptrdiff_t off = dest - s;
+
+ while (__builtin_expect (destlen >= 4, 0))
+ {
+ c = s[0];
+ s[off] = c;
+ if (c == '\0')
+ return dest;
+ c = s[1];
+ s[off + 1] = c;
+ if (c == '\0')
+ return dest;
+ c = s[2];
+ s[off + 2] = c;
+ if (c == '\0')
+ return dest;
+ c = s[3];
+ s[off + 3] = c;
+ if (c == '\0')
+ return dest;
+ destlen -= 4;
+ s += 4;
+ }
do
{
if (__builtin_expect (destlen-- == 0, 0))
- __chk_fail ();
- c = *s++;
- s[off] = c;
+ __chk_fail ();
+ c = *s;
+ *(s++ + off) = c;
}
while (c != '\0');