3 ms·
Really? I just did a "apt-get source libc6" and in strings/eglibc-2.17/string/strcpy.c I found: /* Copy SRC to DEST. */ char * strcpy (dest, src)
by e12e 13y ago
Really? I just did a "apt-get source libc6" and in
strings/eglibc-2.17/string/strcpy.c I found:
/* Copy SRC to DEST. */
char *
strcpy (dest, src)
char *dest;
const char *src;
{
char c;
char *__unbounded s = (char *__unbounded) CHECK_BOUNDS_LOW (src);
const ptrdiff_t off = CHECK_BOUNDS_LOW (dest) - s - 1;
size_t n;
do
{
c = *s++;
s[off] = c;
}
while (c != '\0');
n = s - src;
(void) CHECK_BOUNDS_HIGH (src + n);
(void) CHECK_BOUNDS_HIGH (dest + n);
return dest;
}
- peff 13y agoThat is the fallback implementation in case a platform does not have an optimized version available. Try `sysdeps/x86_64/strcpy.S` to see an optimized version.
- e12e 13y agoOooh, shiny. I'm not very familiar with how this is all tied together, thanks for the pointer. I was a bit thrown by the apparent lack of ifdefs and such in the c definition, but I see the asm-version starts out with: #ifndef USE_AS_STPCPY # define STRCPY strcpy #endif So I guess there is some logic set up in the configure-stage before building.