File:  [DVB] / dietlibc / lib / strcpy.c
Revision 1.6: download - view: text, annotated - select for diffs
Mon Jun 6 11:48:30 2016 UTC (8 years ago) by leitner
Branches: MAIN
CVS tags: HEAD
  add x86_64 memccpy, mempcpy
  import Debian bugfixes (Christian Seiler)

/* fast strcpy -- Copyright (C) 2003 Thomas M. Ogrisegg <tom@hi-tek.fnord.at> */
#include <string.h>
#include "dietfeatures.h"
#include "dietstring.h"

#ifdef WANT_VALGRIND_SUPPORT
extern int __valgrind;
#endif

char *
strcpy (char *s1, const char *s2)
{
    char           *res = s1;
#ifdef WANT_SMALL_STRING_ROUTINES
    while ((*s1++ = *s2++));
    return (res);
#else
    int             tmp;
    unsigned long   l;

    if (UNALIGNED(s1, s2)
#ifdef WANT_VALGRIND_SUPPORT
        || __unlikely(__valgrind)
#endif
    ) {
	while ((*s1++ = *s2++));
	return (res);
    }
    if ((tmp = STRALIGN(s1))) {
	while (tmp-- && (*s1++ = *s2++));
	if (tmp != -1) return (res);
    }

    while (1) {
	l = *(const unsigned long *) s2;
	if (((l - MKW(0x1ul)) & ~l) & MKW(0x80ul)) {
	    while ((*s1++ = GFC(l))) INCSTR(l);
	    return (res);
	}
	*(unsigned long *) s1 = l;
	s2 += sizeof(unsigned long);
	s1 += sizeof(unsigned long);
    }
#endif
}

LinuxTV legacy CVS <linuxtv.org/cvs>