OSDN Git Service

Implement mempcpy
authorEric Andersen <andersen@codepoet.org>
Wed, 9 Jan 2002 19:41:02 +0000 (19:41 -0000)
committerEric Andersen <andersen@codepoet.org>
Wed, 9 Jan 2002 19:41:02 +0000 (19:41 -0000)
include/string.h
libc/string/Makefile
libc/string/string.c

index e0f7e3b..3b2f7cc 100644 (file)
@@ -200,14 +200,15 @@ extern char *strtok_r (char *__restrict __s, __const char *__restrict __delim,
                       char **__restrict __save_ptr) __THROW;
 #endif
 
+#ifdef __USE_GNU
 #if 0
-//#ifdef __USE_GNU
 /* Find the first occurrence of NEEDLE in HAYSTACK.
    NEEDLE is NEEDLELEN bytes long;
    HAYSTACK is HAYSTACKLEN bytes long.  */
 extern void *memmem (__const void *__haystack, size_t __haystacklen,
                     __const void *__needle, size_t __needlelen)
      __THROW __attribute_pure__;
+#endif
 
 /* Copy N bytes of SRC to DEST, return pointer to bytes after the
    last written byte.  */
index 90a1b03..c7a4c12 100644 (file)
@@ -28,7 +28,7 @@ MSRC=string.c
 MOBJ=strlen.o strcat.o strcpy.o strchr.o strcmp.o strncat.o strncpy.o \
        strncmp.o strrchr.o strdup.o strndup.o memcpy.o memccpy.o memset.o \
        memmove.o memcmp.o memchr.o ffs.o strnlen.o strxfrm.o stpcpy.o \
-       stpncpy.o memrchr.o 
+       stpncpy.o memrchr.o mempcpy.o
 
 ifeq ($(HAS_LOCALE),true)
        MOBJ += strcoll.o
index 591f875..176ef89 100644 (file)
@@ -308,6 +308,21 @@ void *memcpy(void *dst, const void *src, size_t len)
 }
 #endif
 
+/********************** Function mempcpy ************************************/
+
+#ifdef L_mempcpy
+void *mempcpy(void *dst, const void *src, size_t len)
+{
+       register char *a = dst;
+       register const char *b = src;
+
+       while (len--)
+               *a++ = *b++;
+
+       return (void *) a;
+}
+#endif
+
 /********************** Function memccpy ************************************/
 
 #ifdef L_memccpy