From 4a2e4635253e615678cea6f2c253485d26dde73a Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Sat, 14 Apr 2001 03:33:33 +0000 Subject: [PATCH] Handle endian-ness. Patch from Paul J.Y. Lahaie -Erik --- coreutils/md5sum.c | 9 ++++++++- md5sum.c | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/coreutils/md5sum.c b/coreutils/md5sum.c index ac3462334..a9bbdef36 100644 --- a/coreutils/md5sum.c +++ b/coreutils/md5sum.c @@ -181,7 +181,14 @@ extern void *md5_buffer __P ((const char *buffer, size_t len, void *resblock)); //--------end of md5.h //---------------------------------------------------------------------------- -#define SWAP(n) (n) +/* Handle endian-ness */ +#if __BYTE_ORDER == __LITTLE_ENDIAN + #define SWAP(n) (n) +#else + #define SWAP(n) ((n << 24) | ((n&65280)<<8) | ((n&16711680)>>8) | (n>>24)) +#endif + + /* This array contains the bytes used to pad the buffer to the next 64-byte boundary. (RFC 1321, 3.1: Step 1) */ diff --git a/md5sum.c b/md5sum.c index ac3462334..a9bbdef36 100644 --- a/md5sum.c +++ b/md5sum.c @@ -181,7 +181,14 @@ extern void *md5_buffer __P ((const char *buffer, size_t len, void *resblock)); //--------end of md5.h //---------------------------------------------------------------------------- -#define SWAP(n) (n) +/* Handle endian-ness */ +#if __BYTE_ORDER == __LITTLE_ENDIAN + #define SWAP(n) (n) +#else + #define SWAP(n) ((n << 24) | ((n&65280)<<8) | ((n&16711680)>>8) | (n>>24)) +#endif + + /* This array contains the bytes used to pad the buffer to the next 64-byte boundary. (RFC 1321, 3.1: Step 1) */ -- 2.25.1