This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[RFC 4/*] Improve strcpy_chk/stpcpy_chk
- From: OndÅej BÃlka <neleai at seznam dot cz>
- To: libc-alpha at sourceware dot org
- Date: Wed, 4 Sep 2013 03:02:31 +0200
- Subject: [RFC 4/*] Improve strcpy_chk/stpcpy_chk
- Authentication-results: sourceware.org; auth=none
- References: <20130904000359 dot GA11634 at domone dot kolej dot mff dot cuni dot cz>
A checked strcpy/stpcpy are currently slow due to assembly implementation.
We could improve speed by using c implementation like:
char *strcpy_chk(char *dest, char *src)
{
size_t n=strlen(src);
/* Check for overlap. */
return memcpy(dest,src,n);
}
simple_stpcpy_chk normal_stpcpy __stpcpy_chk
Length 32, alignment 6/ 4: 42 0 15
Length 64, alignment 0/ 0: 124 0 9
Length 64, alignment 5/ 6: 160 0 27
Length 128, alignment 0/ 0: 226 3 24
Length 128, alignment 4/ 0: 226 6 39
Length 256, alignment 0/ 0: 453 15 57
Length 256, alignment 3/ 2: 453 12 69
Length 512, alignment 0/ 0: 897 33 142
Length 512, alignment 2/ 4: 1094 30 196
Length 1024, alignment 0/ 0: 1792 63 299
Length 1024, alignment 1/ 6: 2239 66 399