This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Patch to add mempcpy and stpcpy to libiberty


This patch adds two new functions, mempcpy and stpcpy to libiberty.
Given the sizes of the function bodies, (one and two lines
respectively) I wasn't sure whether they were copyrightable.  If they
are, let me know and I'll use the LGPL.  (My disclaimer for LIBIBERTY
is in place if that's an issue.)

I tested this with "make all" in libiberty on sparc-sun-solaris2.7.
Since that platform doesn't provide those functions, the libiberty
copies were built and included in the library.

Ok for mainline?

		Thanks,
		--Kaveh


2003-04-15  Kaveh R. Ghazi  <ghazi at caip dot rutgers dot edu>

	* mempcpy.c, stpcpy.c: New files.
	* configure.in (funcs, AC_CHECK_FUNCS): Add mempcpy and stpcpy.
	* Makefile.in (CFILES): Add mempcpy.c and stpcpy.c.
	(CONFIGURED_OFILES): Add mempcpy.o and stpcpy.o.
	Regenerate dependencies.

	* configure, config.in: Regenerated.

diff -rup orig/egcc-CVS20030415/libiberty/mempcpy.c egcc-CVS20030415/libiberty/mempcpy.c
--- orig/egcc-CVS20030415/libiberty/mempcpy.c	2003-04-15 11:58:30.736757000 -0400
+++ egcc-CVS20030415/libiberty/mempcpy.c	2003-04-15 12:10:04.691617000 -0400
@@ -0,0 +1,17 @@
+#include <ansidecl.h>
+#ifdef ANSI_PROTOTYPES
+#include <stddef.h>
+#else
+#define size_t unsigned long
+#endif
+
+extern PTR memcpy PARAMS ((PTR, const PTR, size_t));
+
+PTR
+mempcpy (dst, src, len)
+     PTR dst;
+     const PTR src;
+     size_t len;
+{
+  return (char *) memcpy (dst, src, len) + len;
+}
diff -rup orig/egcc-CVS20030415/libiberty/stpcpy.c egcc-CVS20030415/libiberty/stpcpy.c
--- orig/egcc-CVS20030415/libiberty/stpcpy.c	2003-04-15 11:58:41.215874000 -0400
+++ egcc-CVS20030415/libiberty/stpcpy.c	2003-04-15 12:10:15.700757000 -0400
@@ -0,0 +1,18 @@
+#include <ansidecl.h>
+#ifdef ANSI_PROTOTYPES
+#include <stddef.h>
+#else
+#define size_t unsigned long
+#endif
+
+extern size_t strlen PARAMS ((const char *));
+extern PTR memcpy PARAMS ((PTR, const PTR, size_t));
+
+char *
+stpcpy (dst, src)
+     char *dst;
+     const char *src;
+{
+  const size_t len = strlen (src);
+  return (char *) memcpy (dst, src, len + 1) + len;
+}
diff -rup orig/egcc-CVS20030415/libiberty/configure.in egcc-CVS20030415/libiberty/configure.in
--- orig/egcc-CVS20030415/libiberty/configure.in	2003-04-14 10:24:36.000000000 -0400
+++ egcc-CVS20030415/libiberty/configure.in	2003-04-15 12:10:04.701618000 -0400
@@ -177,6 +177,7 @@ funcs="$funcs memchr"
 funcs="$funcs memcmp"
 funcs="$funcs memcpy"
 funcs="$funcs memmove"
+funcs="$funcs mempcpy"
 funcs="$funcs memset"
 funcs="$funcs mkstemps"
 funcs="$funcs putenv"
@@ -185,6 +186,7 @@ funcs="$funcs rename"
 funcs="$funcs rindex"
 funcs="$funcs setenv"
 funcs="$funcs sigsetmask"
+funcs="$funcs stpcpy"
 funcs="$funcs strcasecmp"
 funcs="$funcs strchr"
 funcs="$funcs strdup"
@@ -214,8 +216,8 @@ checkfuncs="$checkfuncs getsysinfo table
 if test "x" = "y"; then
   AC_CHECK_FUNCS(asprintf atexit basename bcmp bcopy bsearch bzero calloc clock)
   AC_CHECK_FUNCS(getcwd getpagesize index insque mkstemps memchr memcmp memcpy)
-  AC_CHECK_FUNCS(memmove memset putenv random rename rindex sigsetmask)
-  AC_CHECK_FUNCS(strcasecmp setenv strchr strdup strncasecmp strrchr strstr)
+  AC_CHECK_FUNCS(memmove mempcpy memset putenv random rename rindex sigsetmask)
+  AC_CHECK_FUNCS(strcasecmp setenv stpcpy strchr strdup strncasecmp strrchr strstr)
   AC_CHECK_FUNCS(strtod strtol strtoul tmpnam vasprintf vfprintf vprintf)
   AC_CHECK_FUNCS(vsprintf waitpid getrusage on_exit psignal strerror strsignal)
   AC_CHECK_FUNCS(sysconf times sbrk gettimeofday ffs)
diff -rup orig/egcc-CVS20030415/libiberty/Makefile.in egcc-CVS20030415/libiberty/Makefile.in
--- orig/egcc-CVS20030415/libiberty/Makefile.in	2003-04-15 12:09:39.573564000 -0400
+++ egcc-CVS20030415/libiberty/Makefile.in	2003-04-15 12:10:25.259921000 -0400
@@ -140,7 +140,7 @@ CFILES = alloca.c argv.c asprintf.c atex
 	lrealpath.c							\
 	make-relative-prefix.c						\
 	make-temp-file.c md5.c memchr.c memcmp.c memcpy.c memmove.c	\
-	 memset.c mkstemps.c						\
+	 mempcpy.c memset.c mkstemps.c					\
 	objalloc.c obstack.c						\
 	partition.c							\
 	 pex-djgpp.c pex-mpw.c pex-msdos.c pex-os2.c			\
@@ -148,9 +148,9 @@ CFILES = alloca.c argv.c asprintf.c atex
          physmem.c putenv.c						\
 	random.c regex.c rename.c rindex.c				\
 	safe-ctype.c setenv.c sigsetmask.c sort.c spaces.c		\
-	 splay-tree.c strcasecmp.c strchr.c strdup.c strerror.c		\
-	 strncasecmp.c strncmp.c strrchr.c strsignal.c strstr.c		\
-	 strtod.c strtol.c strtoul.c					\
+	 splay-tree.c stpcpy.c strcasecmp.c strchr.c strdup.c		\
+	 strerror.c strncasecmp.c strncmp.c strrchr.c strsignal.c	\
+	 strstr.c strtod.c strtol.c strtoul.c				\
 	ternary.c tmpnam.c						\
 	vasprintf.c vfork.c vfprintf.c vprintf.c vsprintf.c		\
 	waitpid.c							\
@@ -186,12 +186,12 @@ CONFIGURED_OFILES = asprintf.o atexit.o	
 	ffs.o								\
 	getcwd.o getpagesize.o						\
 	index.o insque.o						\
-	memchr.o memcmp.o memcpy.o memmove.o memset.o mkstemps.o	\
+	memchr.o memcmp.o memcpy.o memmove.o mempcpy.o memset.o mkstemps.o \
 	pex-djgpp.o pex-mpw.o pex-msdos.o pex-os2.o			\
 	 pex-unix.o pex-win32.o						\
 	 putenv.o							\
 	random.o rename.o rindex.o					\
-	setenv.o sigsetmask.o strcasecmp.o strchr.o strdup.o		\
+	setenv.o sigsetmask.o stpcpy.o strcasecmp.o strchr.o strdup.o	\
 	 strncasecmp.o strncmp.o strrchr.o strstr.o strtod.o strtol.o	\
 	 strtoul.o							\
 	tmpnam.o							\
@@ -459,6 +459,7 @@ memchr.o: $(INCDIR)/ansidecl.h
 memcmp.o: $(INCDIR)/ansidecl.h
 memcpy.o: $(INCDIR)/ansidecl.h
 memmove.o: $(INCDIR)/ansidecl.h
+mempcpy.o: $(INCDIR)/ansidecl.h
 memset.o: $(INCDIR)/ansidecl.h
 mkstemps.o: config.h $(INCDIR)/ansidecl.h
 objalloc.o: config.h $(INCDIR)/ansidecl.h $(INCDIR)/objalloc.h
@@ -479,6 +480,7 @@ sort.o: config.h $(INCDIR)/ansidecl.h $(
 spaces.o: $(INCDIR)/ansidecl.h $(INCDIR)/libiberty.h
 splay-tree.o: config.h $(INCDIR)/ansidecl.h $(INCDIR)/libiberty.h \
 	$(INCDIR)/splay-tree.h
+stpcpy.o: $(INCDIR)/ansidecl.h
 strcasecmp.o: $(INCDIR)/ansidecl.h
 strchr.o: $(INCDIR)/ansidecl.h
 strdup.o: $(INCDIR)/ansidecl.h


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]