summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2002-01-09 19:41:02 +0000
committerEric Andersen <andersen@codepoet.org>2002-01-09 19:41:02 +0000
commitdb777744aa07d47a571016b48fea82e53371fe2b (patch)
treef77a343835c1bec2d40612992a3e68501ffdf110
parent2f2e72cbed35ff28d89ef16dbbea4497de834617 (diff)
Implement mempcpy
-rw-r--r--include/string.h3
-rw-r--r--libc/string/Makefile2
-rw-r--r--libc/string/string.c15
3 files changed, 18 insertions, 2 deletions
diff --git a/include/string.h b/include/string.h
index e0f7e3bcb..3b2f7cc81 100644
--- a/include/string.h
+++ b/include/string.h
@@ -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. */
diff --git a/libc/string/Makefile b/libc/string/Makefile
index 90a1b03a1..c7a4c128a 100644
--- a/libc/string/Makefile
+++ b/libc/string/Makefile
@@ -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
diff --git a/libc/string/string.c b/libc/string/string.c
index 591f875f9..176ef895b 100644
--- a/libc/string/string.c
+++ b/libc/string/string.c
@@ -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