diff options
author | David Schleef <ds@schleef.org> | 2004-11-04 20:54:31 +0000 |
---|---|---|
committer | David Schleef <ds@schleef.org> | 2004-11-04 20:54:31 +0000 |
commit | adff277210ba86a98b577967b8e52d0176abba02 (patch) | |
tree | 1f1ba39590e4e93bff24981cfb96d592911e8ce9 /examples | |
parent | 056758c82870a6c74e53acb05ebb8abe1bd2d9b7 (diff) | |
download | liboil-adff277210ba86a98b577967b8e52d0176abba02.tar.gz |
* configure.ac: add endianness check
* examples/md5/md5sum.c: (main): endianness fixes
* liboil/md5/md5.c: (md5_c): endianness fixes
* liboil/md5/md5_powerpc.c: (md5_asm1), (md5_asm2), (md5_asm3): some
asm implementations
* testsuite/Makefile.am:
* testsuite/md5.c: (test): endianness fixes
* testsuite/md5_profile.c: (test), (main): Add a profiling tool
for md5.
Diffstat (limited to 'examples')
-rw-r--r-- | examples/md5/md5sum.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/examples/md5/md5sum.c b/examples/md5/md5sum.c index 416c4bd..f0a93ee 100644 --- a/examples/md5/md5sum.c +++ b/examples/md5/md5sum.c @@ -1,4 +1,8 @@ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include <stdio.h> #include <liboil/liboil.h> #include <liboil/liboilfuncs.h> @@ -8,6 +12,13 @@ #include <sys/mman.h> #include <fcntl.h> +#ifdef WORDS_BIGENDIAN +#define uint32_from_host(a) \ + ((((a)&0xff)<<24)|(((a)&0xff00)<<8)|(((a)&0xff0000)>>8)|(((a)>>24)&0xff)) +#else +#define uint32_from_host(a) (a) +#endif + #if 0 int main(int argc, char *argv[]) { @@ -127,7 +138,8 @@ int main(int argc, char *argv[]) for(;n<56;n++) buffer[n] = 0; - *(uint64_t *)(buffer + 56) = n_bytes << 3; + *(uint32_t *)(buffer + 56) = uint32_from_host (n_bytes << 3); + *(uint32_t *)(buffer + 60) = uint32_from_host (n_bytes >>29); oil_md5 (state, (uint32_t *)buffer); printf("%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x\n", |