]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR other/13906 (genmodes.c:964: internal compiler error: Bus error in...
authorKaveh R. Ghazi <ghazi@caip.rutgers.edu>
Mon, 6 Feb 2006 14:06:55 +0000 (14:06 +0000)
committerKaveh Ghazi <ghazi@gcc.gnu.org>
Mon, 6 Feb 2006 14:06:55 +0000 (14:06 +0000)
include:

Backport:
2006-01-18  DJ Delorie  <dj@redhat.com>

* md5.h: Include ansidecl.h

2005-07-03  Steve Ellcey  <sje@cup.hp.com>

PR other/13906
* ansidecl.h (ATTRIBUTE_ALIGNED_ALIGNOF): New.
* md5.h (md5_uintptr): New.
(md5_ctx): Align buffer field.

libiberty:

Backport:
2005-07-03  Steve Ellcey  <sje@cup.hp.com>

PR other/13906
* md5.c (md5_process_bytes): Check alignment.

From-SVN: r110643

include/ChangeLog
include/ansidecl.h
include/md5.h
libiberty/ChangeLog
libiberty/md5.c

index 3662517c69db20cae24e232e5174aad8b8e52951..de5f23a6bb3ffd60b304e9f1774f66ef85e52905 100644 (file)
@@ -1,3 +1,17 @@
+2006-02-06  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
+
+       Backport:
+       2006-01-18  DJ Delorie  <dj@redhat.com>
+
+       * md5.h: Include ansidecl.h
+       
+       2005-07-03  Steve Ellcey  <sje@cup.hp.com>
+
+       PR other/13906
+       * ansidecl.h (ATTRIBUTE_ALIGNED_ALIGNOF): New.
+       * md5.h (md5_uintptr): New.
+       (md5_ctx): Align buffer field.
+
 2005-11-30  Release Manager
 
        * GCC 3.4.5 released.
index d2c87768ce2ef6336c7f240b055a4b5e145c4976..ee0aecf22de831bdd36822bc60378f3c37a2c385 100644 (file)
@@ -305,6 +305,15 @@ So instead we use the macro below and test it against specific values.  */
 # define ATTRIBUTE_NULL_PRINTF_5 ATTRIBUTE_NULL_PRINTF(5, 6)
 #endif /* ATTRIBUTE_NULL_PRINTF */
 
+
+#ifndef ATTRIBUTE_ALIGNED_ALIGNOF
+# if (GCC_VERSION >= 3000)
+#  define ATTRIBUTE_ALIGNED_ALIGNOF(m) __attribute__ ((__aligned__ (__alignof__ (m))))
+# else
+#  define ATTRIBUTE_ALIGNED_ALIGNOF(m)
+# endif /* GNUC >= 3.0 */
+#endif /* ATTRIBUTE_ALIGNED_ALIGNOF */
+
 /* We use __extension__ in some places to suppress -pedantic warnings
    about GCC extensions.  This feature didn't work properly before
    gcc 2.8.  */
index ad51f19877a29f568c44763eb6bd7fcbe5a007eb..4d6161c323614bbe83dd290793165f36492c91a7 100644 (file)
@@ -27,6 +27,8 @@
 # include <limits.h>
 #endif
 
+#include "ansidecl.h"
+
 /* The following contortions are an attempt to use the C preprocessor
    to determine an unsigned integral type that is 32 bits wide.  An
    alternative approach is to use autoconf's AC_CHECK_SIZEOF macro, but
@@ -37,6 +39,7 @@
 #ifdef _LIBC
 # include <sys/types.h>
 typedef u_int32_t md5_uint32;
+typedef uintptr_t md5_uintptr;
 #else
 #  define INT_MAX_32_BITS 2147483647
 
@@ -64,6 +67,9 @@ typedef u_int32_t md5_uint32;
 #   endif
 #  endif
 # endif
+/* We have to make a guess about the integer type equivalent in size
+   to pointers which should always be correct.  */
+typedef unsigned long int md5_uintptr;
 #endif
 
 #undef __P
@@ -83,7 +89,7 @@ struct md5_ctx
 
   md5_uint32 total[2];
   md5_uint32 buflen;
-  char buffer[128];
+  char buffer[128] ATTRIBUTE_ALIGNED_ALIGNOF(md5_uint32);
 };
 
 /*
index 02c79baf8c5f254c3710fa5dd3fbd39633177757..f0b0cec5e20eac5f6d6db9cb050119faa7720da2 100644 (file)
@@ -1,3 +1,11 @@
+2006-02-06  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
+
+       Backport:
+       2005-07-03  Steve Ellcey  <sje@cup.hp.com>
+
+       PR other/13906
+       * md5.c (md5_process_bytes): Check alignment.
+
 2005-11-30  Release Manager
 
        * GCC 3.4.5 released.
index e458f2a6a6412da925c0a6733910210c75bfe761..7a202d8c1231e3ab9c542f7a93e678c45cf0fd9f 100644 (file)
@@ -236,6 +236,23 @@ md5_process_bytes (buffer, len, 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;