You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by st...@apache.org on 2013/06/20 17:53:33 UTC

svn commit: r1495063 - /subversion/trunk/subversion/libsvn_fs_fs/tree.c

Author: stsp
Date: Thu Jun 20 15:53:32 2013
New Revision: 1495063

URL: http://svn.apache.org/r1495063
Log:
* subversion/libsvn_fs_fs/tree.c
  (cache_lookup): Calculate hash_value in an alternative way on
  strict-alignment architectures, such as Solaris/sparc. Wrap the current
  calculation in SVN_UNALIGNED_ACCESS_IS_OK to ensure that it is only
  used on platforms which support unaligned access.

Found by: Rainer Jung <rj...@apache.org>
Thanks to Sergey Raevskiy for spotting a bug in my initial patch.

Modified:
    subversion/trunk/subversion/libsvn_fs_fs/tree.c

Modified: subversion/trunk/subversion/libsvn_fs_fs/tree.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/tree.c?rev=1495063&r1=1495062&r2=1495063&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/tree.c (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/tree.c Thu Jun 20 15:53:32 2013
@@ -354,7 +354,19 @@ cache_lookup( fs_fs_dag_cache_t *cache
   /* need to do a full lookup.  Calculate the hash value
      (HASH_VALUE has been initialized to REVISION). */
   for (i = 0; i + 4 <= path_len; i += 4)
+#if SVN_UNALIGNED_ACCESS_IS_OK
     hash_value = hash_value * 0xd1f3da69 + *(const apr_uint32_t*)(path + i);
+#else
+    {
+      apr_uint32_t val = 0;
+      int j;
+
+      for (j = 0; j < 4; j++)
+        val |= (path[i + j] << (j * 8));
+
+      hash_value = hash_value * 0xd1f3da69 + val;
+    }
+#endif
 
   for (; i < path_len; ++i)
     hash_value = hash_value * 33 + path[i];