]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR other/13906 (genmodes.c:964: internal compiler error: Bus error in md5_process_...
authorSteve Ellcey <sje@cup.hp.com>
Sun, 3 Jul 2005 15:40:29 +0000 (15:40 +0000)
committerSteve Ellcey <sje@gcc.gnu.org>
Sun, 3 Jul 2005 15:40:29 +0000 (15:40 +0000)
PR other/13906
* md5.c (md5_process_bytes): Check alignment.

From-SVN: r101557

libiberty/ChangeLog
libiberty/md5.c

index eb19aa71e4c041ecd1a9d078f0bb6fadb738f12d..ba575549ada701284722f8f65a0f4fcbbff4f751 100644 (file)
@@ -1,3 +1,8 @@
+2005-07-03  Steve Ellcey  <sje@cup.hp.com>
+
+       PR other/13906
+       * md5.c (md5_process_bytes): Check alignment.
+
 2005-07-01  Ian Lance Taylor  <ian@airs.com>
 
        PR other/22268
index c03a74dffa2c8bbcf4a79816f1c0689c80226011..83e0beb339fa2a6c0beb80618b7a8306a075ab00 100644 (file)
@@ -223,6 +223,23 @@ md5_process_bytes (const void *buffer, size_t len, struct md5_ctx *ctx)
   /* Process available complete blocks.  */
   if (len > 64)
     {
+#if !_STRING_ARCH_unaligned
+/* To check alignment gcc has an appropriate operator.  Other
+   compilers don't.  */
+# if __GNUC__ >= 2
+#  define UNALIGNED_P(p) (((md5_uintptr) p) % __alignof__ (md5_uint32) != 0)
+# else
+#  define UNALIGNED_P(p) (((md5_uintptr) p) % sizeof (md5_uint32) != 0)
+# endif
+      if (UNALIGNED_P (buffer))
+        while (len > 64)
+          {
+            md5_process_block (memcpy (ctx->buffer, buffer, 64), 64, ctx);
+            buffer = (const char *) buffer + 64;
+            len -= 64;
+          }
+      else
+#endif
       md5_process_block (buffer, len & ~63, ctx);
       buffer = (const void *) ((const char *) buffer + (len & ~63));
       len &= 63;