rpms/mhash/F-10 mutils-align.patch,NONE,1.1 mhash.spec,1.25,1.26

Dennis Gilmore ausil at fedoraproject.org
Mon Feb 16 16:25:51 UTC 2009


Author: ausil

Update of /cvs/pkgs/rpms/mhash/F-10
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv21976

Modified Files:
	mhash.spec 
Added Files:
	mutils-align.patch 
Log Message:
add patch for memory alignment issues


mutils-align.patch:

--- NEW FILE mutils-align.patch ---
diff -ur mhash-0.9.9.orig/lib/stdfns.c mhash-0.9.9/lib/stdfns.c
--- mhash-0.9.9.orig/lib/stdfns.c	Wed Apr  4 21:18:42 2007
+++ mhash-0.9.9/lib/stdfns.c	Mon May 28 16:08:38 2007
@@ -152,12 +152,23 @@
 	}
 }
 
+static void
+mutils_memset8(void *s, __const mutils_word8 c, __const mutils_word32 n)
+{
+	mutils_word8 *stmp = s;
+	mutils_word32 i;
+
+	for (i = 0; i < n; i++, stmp++)
+	{
+		*stmp = c;
+	}
+}
+
 WIN32DLL_DEFINE
 void
 mutils_memset(void *s, __const mutils_word8 c, __const mutils_word32 n)
 {
-	mutils_word8 *stmp;
-	mutils_word32 *ltmp = (mutils_word32 *) s;
+	mutils_word32 *ltmp;
 	mutils_word32 lump;
 	mutils_word32 i;
 	mutils_word32 words;
@@ -168,10 +179,22 @@
 		return;
 	}
 
+	if (n < 16)
+	{
+		return mutils_memset8(s, c, n);
+	}
+
+	/* unaligned portion at beginning */
+	remainder = (-(mutils_word32)s) & 0x3;
+	mutils_memset8(s, c, remainder);
+
+	/* aligned words in the middle */
+	ltmp = (mutils_word32 *) (s + remainder);
+
 	lump = (c << 24) + (c << 16) + (c << 8) + c;
 
-	words = n >> 2;
-	remainder = n - (words << 2);
+	words = (n - remainder) >> 2;
+	remainder = n - remainder - (words << 2);
 
 	for (i = 0; i < words; i++, ltmp++)
 	{
@@ -178,12 +201,8 @@
 		*ltmp = lump;
 	}
 
-	stmp = (mutils_word8 *) ltmp;
-
-	for (i = 0; i < remainder; i++, stmp++)
-	{
-		*stmp = c;
-	}
+	/* unaligned portion at end */
+	return mutils_memset8(ltmp, c, remainder);
 }
 
 static void
@@ -275,6 +294,9 @@
 	mutils_word32 *buffer;
 	mutils_word32 *ptrIn;
 	mutils_word32 *ptrOut;
+	mutils_word8 *ptr8In;
+	mutils_word8 *ptr8Out;
+	mutils_word8 tmp8;
 	mutils_word32 count = n * 4;
 
 	if (destructive == MUTILS_FALSE)
@@ -295,10 +317,36 @@
  * data on a little-endian machine.
  */
 
-	for (loop = 0, ptrIn = x, ptrOut = buffer; loop < n; loop++, ptrOut++, ptrIn++)
+	if ((mutils_word32)x & 0x3)
 	{
-		*ptrOut = mutils_lend32(*ptrIn);
+	  ptr8In = (mutils_word8 *) x;
+	  ptr8Out = (mutils_word8 *) buffer;
+	  for (loop = 0; loop < n; loop++)
+	    {
+#ifdef WORDS_BIGENDIAN
+	      tmp8 = ptr8In[0];
+	      ptr8Out[0] = ptr8In[3];
+	      ptr8Out[3] = tmp8;
+	      tmp8 = ptr8In[1];
+	      ptr8Out[1] = ptr8In[2];
+	      ptr8Out[2] = tmp8;
+#else
+	      ptr8Out[0] = ptr8In[0];
+	      ptr8Out[1] = ptr8In[1];
+	      ptr8Out[2] = ptr8In[2];
+	      ptr8Out[3] = ptr8In[3];
+#endif
+	      ptr8Out += 4;
+	      ptr8In += 4;
+	    }
 	}
+	else
+	{
+		for (loop = 0, ptrIn = x, ptrOut = buffer; loop < n; loop++, ptrOut++, ptrIn++)
+		{
+			*ptrOut = mutils_lend32(*ptrIn);
+		}
+	}
 
 	return(buffer);
 }


Index: mhash.spec
===================================================================
RCS file: /cvs/pkgs/rpms/mhash/F-10/mhash.spec,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- mhash.spec	20 Feb 2008 01:24:14 -0000	1.25
+++ mhash.spec	16 Feb 2009 16:25:21 -0000	1.26
@@ -4,12 +4,13 @@
 Summary: Thread-safe hash algorithms library
 Name: mhash
 Version: 0.9.9
-Release: 5
+Release: 6
 URL: http://mhash.sourceforge.net/
 License: LGPLv2+
 Group: System Environment/Libraries
 Source: http://download.sourceforge.net/mhash/mhash-%{version}.tar.bz2
 Patch1: mhash-0.9.9-multiarch.patch
+Patch2: mutils-align.patch
 Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot-%(%{__id_u} -n)
 Provides: libmhash = %{version}-%{release}
 
@@ -41,6 +42,7 @@
 %prep
 %setup -q
 %patch1 -p1 -b .multiarch
+%patch2 -p1 -b .alignment
 
 
 %build
@@ -93,6 +95,9 @@
 
 
 %changelog
+* Mon Feb 16 2009 Dennis Gilmore <dennis at ausil.us> - 0.9.9-6
+- fix memory alignment issues
+
 * Tue Feb 19 2008 Fedora Release Engineering <rel-eng at fedoraproject.org> - 0.9.9-5
 - Autorebuild for GCC 4.3
 




More information about the fedora-extras-commits mailing list