aboutsummaryrefslogtreecommitdiff
path: root/libiberty/md5.c
diff options
context:
space:
mode:
authorSteve Ellcey <sje@cup.hp.com>2005-07-03 15:40:29 +0000
committerSteve Ellcey <sje@gcc.gnu.org>2005-07-03 15:40:29 +0000
commit6cbfa10eb5cc91e373681e2957d5b3f0b79ae57f (patch)
treee972d666334ce85e6dc741fe56d68641f7b6659c /libiberty/md5.c
parent3fe725de2a240fe7f3e4c7882841df0259ff7833 (diff)
downloadgcc-6cbfa10eb5cc91e373681e2957d5b3f0b79ae57f.zip
gcc-6cbfa10eb5cc91e373681e2957d5b3f0b79ae57f.tar.gz
gcc-6cbfa10eb5cc91e373681e2957d5b3f0b79ae57f.tar.bz2
re PR other/13906 (genmodes.c:964: internal compiler error: Bus error in md5_process_block)
PR other/13906 * md5.c (md5_process_bytes): Check alignment. From-SVN: r101557
Diffstat (limited to 'libiberty/md5.c')
-rw-r--r--libiberty/md5.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/libiberty/md5.c b/libiberty/md5.c
index c03a74d..83e0beb 100644
--- a/libiberty/md5.c
+++ b/libiberty/md5.c
@@ -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;