diff options
author | Ondřej Bílka <neleai@seznam.cz> | 2015-08-25 12:23:24 +0200 |
---|---|---|
committer | Ondřej Bílka <neleai@seznam.cz> | 2015-08-25 15:06:33 +0200 |
commit | 0d0325ed4b1052f32069eb3a51f7e16485a73568 (patch) | |
tree | 78fdda7e7fab4a93d3789d8244fbec6e93d9b65e /debug/stpcpy_chk.c | |
parent | f3dcae82d54e5097e18e1d6ef4ff55c2ea4e621e (diff) | |
download | glibc-0d0325ed4b1052f32069eb3a51f7e16485a73568.tar glibc-0d0325ed4b1052f32069eb3a51f7e16485a73568.tar.gz glibc-0d0325ed4b1052f32069eb3a51f7e16485a73568.tar.bz2 glibc-0d0325ed4b1052f32069eb3a51f7e16485a73568.zip |
Fix strcpy_chk and stpcpy_chk performance.
Hi, as I wrote in previous patches a performance of checked strcpy and
stpcpy is terrible as these don't use sse2 and are around four times
slower that strcpy and stpcpy now.
As this bug shows that these functions are not performance sensitive I
decided just to improve generic implementation instead for easier
maintainance.
* debug/strcpy_chk.c: Improve performance.
* debug/stpcpy_chk.c: Likewise.
* sysdeps/x86_64/strcpy_chk.S: Remove.
* sysdeps/x86_64/stpcpy_chk.S: Remove.
Diffstat (limited to 'debug/stpcpy_chk.c')
-rw-r--r-- | debug/stpcpy_chk.c | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/debug/stpcpy_chk.c b/debug/stpcpy_chk.c index 91c50316ec..d9e4563cff 100644 --- a/debug/stpcpy_chk.c +++ b/debug/stpcpy_chk.c @@ -24,21 +24,11 @@ /* Copy SRC to DEST, returning the address of the terminating '\0' in DEST. */ char * -__stpcpy_chk (dest, src, destlen) - char *dest; - const char *src; - size_t destlen; +__stpcpy_chk (char *dest, const char *src, size_t destlen) { - char *d = dest; - const char *s = src; - - do - { - if (__glibc_unlikely (destlen-- == 0)) - __chk_fail (); - *d++ = *s; - } - while (*s++ != '\0'); - - return d - 1; + size_t len = strlen (src); + if (len >= destlen) + __chk_fail (); + + return memcpy (dest, src, len + 1) + len; } |