diff options
| author | knu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2001-05-16 22:14:01 +0000 |
|---|---|---|
| committer | knu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2001-05-16 22:14:01 +0000 |
| commit | 4f0e963086c331ea4279e2b8b581597a0eff8d69 (patch) | |
| tree | 239838d1ef769be5fa391cd8dcafde7fbc6fe6e2 | |
| parent | 58554c601e2f1ebf65d724fb6d3761dba31e6fb5 (diff) | |
| download | ruby-4f0e963086c331ea4279e2b8b581597a0eff8d69.tar.gz ruby-4f0e963086c331ea4279e2b8b581597a0eff8d69.tar.xz ruby-4f0e963086c331ea4279e2b8b581597a0eff8d69.zip | |
* ext/sha1/extconf.rb, ext/sha1/sha1.c: use WORDS_BIGENDIAN to
detect the platform's endian.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@1409 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
| -rw-r--r-- | ChangeLog | 5 | ||||
| -rw-r--r-- | ext/sha1/extconf.rb | 12 | ||||
| -rw-r--r-- | ext/sha1/sha1.c | 7 |
3 files changed, 8 insertions, 16 deletions
@@ -1,3 +1,8 @@ +Thu May 17 07:11:35 2001 Akinori MUSHA <knu@iDaemons.org> + + * ext/sha1/extconf.rb, ext/sha1/sha1.c: use WORDS_BIGENDIAN to + detect the platform's endian. + Thu May 17 06:31:30 2001 Akinori MUSHA <knu@iDaemons.org> * ext/md5/md5.txt: make wording fixes, and mention the newly added diff --git a/ext/sha1/extconf.rb b/ext/sha1/extconf.rb index 0a293e124..32e46cf3d 100644 --- a/ext/sha1/extconf.rb +++ b/ext/sha1/extconf.rb @@ -1,15 +1,3 @@ require 'mkmf' -i = 0x01020304 - -case [i].pack('l') - when [i].pack('V') - $CFLAGS += " -DLITTLE_ENDIAN" - when [i].pack('N') - $CFLAGS += " -DBIG_ENDIAN" - else - p "Sorry, your machine has an unusual byte order which is not supported." - exit! -end - create_makefile('sha1') diff --git a/ext/sha1/sha1.c b/ext/sha1/sha1.c index afcc297cb..f6f9fa88f 100644 --- a/ext/sha1/sha1.c +++ b/ext/sha1/sha1.c @@ -12,7 +12,6 @@ A million repetitions of "a" 34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F */ -/* #define LITTLE_ENDIAN * This should be #define'd if true. */ /* #define SHA1HANDSOFF * Copies data before messing with it. */ #include "sha1.h" @@ -21,11 +20,11 @@ A million repetitions of "a" /* blk0() and blk() perform the initial expand. */ /* I got the idea of expanding during the round function from SSLeay */ -#ifdef LITTLE_ENDIAN +#ifdef WORDS_BIGENDIAN +#define blk0(i) block->l[i] +#else /* LITTLE ENDIAN */ #define blk0(i) (block->l[i] = (rol(block->l[i],24)&0xFF00FF00) \ |(rol(block->l[i],8)&0x00FF00FF)) -#else -#define blk0(i) block->l[i] #endif #define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \ ^block->l[(i+2)&15]^block->l[i&15],1)) |
