rpms/dietlibc/F-8 dietlibc-0.31.20080221-memcpy.patch, NONE, 1.1 dietlibc.spec, 1.42, 1.43

Enrico Scholz (ensc) fedora-extras-commits at redhat.com
Sat Jun 21 13:43:52 UTC 2008


Author: ensc

Update of /cvs/extras/rpms/dietlibc/F-8
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv23756

Modified Files:
	dietlibc.spec 
Added Files:
	dietlibc-0.31.20080221-memcpy.patch 
Log Message:
fixed optimized memcpy(3)


dietlibc-0.31.20080221-memcpy.patch:

--- NEW FILE dietlibc-0.31.20080221-memcpy.patch ---
2008-02-22  Enrico Scholz  <enrico.scholz at informatik.tu-chemnitz.de>

	- fixed memcpy(3) for unaligned buffers; previously, code like

	  | test[15] = 'a';
	  | test[31] = 'b';
	  | memcpy(test+7, test+23, 9);
	  | assert(test[15]==test[31]);

	  failed

	- added memcmpy(3) testcase for all (?) possible alignments

--- dietlibc-0.31.20080221/lib/memcpy.c.memcpy	2003-12-21 13:06:36.000000000 +0100
+++ dietlibc-0.31.20080221/lib/memcpy.c	2008-02-22 18:51:52.000000000 +0100
@@ -28,6 +28,8 @@ memcpy (void *dst, const void *src, size
 		*c1++ = *c2++;
 	    if (n == (size_t) - 1)
 		return (res);
+	    dst = c1;
+	    src = c2;
 	}
 
 	lx1 = (unsigned long *) dst;
--- dietlibc-0.31.20080221/test/string/memcpy.c.memcpy	2003-12-15 14:07:42.000000000 +0100
+++ dietlibc-0.31.20080221/test/string/memcpy.c	2008-02-22 18:53:58.000000000 +0100
@@ -1,11 +1,52 @@
 #include <string.h>
 #include <assert.h>
+#include <sys/param.h>
+
+#define WO	(__WORDSIZE/8)
 
 int main() {
+  size_t const	LENS[] = {
+    1, 2, 3, 4, 5, 6, 7, 8,
+    WO  -3, WO  -2, WO  -1,  WO,   WO  +1, WO  +2, WO  +3, WO  +4,
+    WO*2-3, WO*2-2, WO*2-1,  WO*2, WO*2+1, WO*2+2, WO*2+3, WO*2+4,
+    WO*3-3, WO*3-2, WO*3-1,  WO*3, WO*3+1, WO*3+2, WO*3+3, WO*3+4,
+    (size_t)(-1) };
+
+  size_t i,j;
+  size_t const *len;
   char test[100]="blubber";
+
   assert(memcpy(test,"blubber",8)==test);
   assert(!memcmp(test,"blubber",8));
   assert(memcpy(0,0,0)==0);
   assert(memcpy(test,"foobar",3) && test[2]=='o');
+
+  /* test all possible alignments of src and destination in combination with
+   * some interesting lengths */
+  for (len=LENS+0; *len!=(size_t)(-1); ++len) {
+    unsigned char	src[WO * 5];
+
+    for (i=0; i<*len + WO; ++i)
+      src[i] = i;
+
+    for (i=MIN(WO,*len); i>0;) {
+      --i;
+      
+      for (j=MIN(WO,*len); j>0;) {
+	unsigned char	dst[WO * 5];
+	size_t k;
+	--j;
+
+	for (k=0; k<*len; ++k)
+	  dst[j+k]=src[i+k]+1;
+			  
+	assert(memcpy(dst+j, src+i, *len)==dst+j);
+
+	for (k=0; k<*len; ++k)
+	  assert(dst[j+k]==src[i+k]);
+      }
+    }
+  }
+
   return 0;
 }


Index: dietlibc.spec
===================================================================
RCS file: /cvs/extras/rpms/dietlibc/F-8/dietlibc.spec,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -r1.42 -r1.43
--- dietlibc.spec	21 Jun 2008 13:41:48 -0000	1.42
+++ dietlibc.spec	21 Jun 2008 13:43:05 -0000	1.43
@@ -50,6 +50,7 @@
 Patch32:	dietlibc-0.31-stacksmash.patch
 Patch33:	dietlibc-0.31-stacksmash-dyn.patch
 Patch41:	dietlibc-0.31.20080212-teststdout.patch
+Patch42:	dietlibc-0.31.20080221-memcpy.patch
 BuildRoot:	%_tmppath/%name-%version-%release-buildroot
 %{?with_dynamic:Requires:	dietlibc-lib = %version-%release}
 %{!?with_dynamic:Obsoletes:	dietlibc-lib < %version-%release}
@@ -99,6 +100,7 @@
 %patch33 -p1 -b .stacksmash-dyn
 
 %patch41 -p1 -b .teststdout
+%patch42 -p1 -b .memcpy
 
 
 %if %{without ssp}
@@ -141,7 +143,7 @@
 
 
 %check
-XTRA_CFLAGS='-fno-builtin'
+XTRA_CFLAGS='-fno-builtin -g3 -O0'
 make %makeflags -C test      all %{?_smp_mflags} DIET=$(echo `pwd`/bin-*/diet) -k || :
 make %makeflags -C test/inet all %{?_smp_mflags} DIET=$(echo `pwd`/bin-*/diet)    || :
 
@@ -186,6 +188,7 @@
 - added -devel subpackage due to multiarch issues; main package contains
   only the 'diet' binary plus some tools while -devel holds all the
   header and object files.
+- fixed optimized memcpy(3)
 
 * Wed Feb 13 2008 Enrico Scholz <enrico.scholz at informatik.tu-chemnitz.de> - 0.31-1.20080212
 - updated to CVS snapshot 20080212




More information about the fedora-extras-commits mailing list