summaryrefslogtreecommitdiff
path: root/libiberty/md5.c
diff options
context:
space:
mode:
authorDJ Delorie <dj@redhat.com>2005-07-03 19:16:20 +0000
committerDJ Delorie <dj@redhat.com>2005-07-03 19:16:20 +0000
commit6ba85b8caf7b49723e475c3563995c44649e23b3 (patch)
tree5b4a6d142c7a5d949dd365dd5bd4c01b563b55e6 /libiberty/md5.c
parent2f4535c7eb76b6a7ceee2e8805a103cb8a90efee (diff)
downloadbinutils-gdb-6ba85b8caf7b49723e475c3563995c44649e23b3.tar.gz
merge from gcc
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 c03a74dffa2..83e0beb339f 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;