summaryrefslogtreecommitdiff
path: root/sysdeps
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2004-10-18 10:00:48 +0000
committerJakub Jelinek <jakub@redhat.com>2004-10-18 10:00:48 +0000
commit3c7dae119e405a26bc23c07820d76bab0fdb0af0 (patch)
treeeb07342df05aa0ef7a32761b59746ea3e3547ade /sysdeps
parent56c4396a6e1568a5511ac43873fa3c9e1ebfa8d1 (diff)
* sysdeps/generic/strcpy_chk.c (__strcpy_chk): Speed up by checking
destlen only every 4 bytes.
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/generic/strcpy_chk.c30
1 files changed, 26 insertions, 4 deletions
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');