diff options
| author | Doug Zongker <dougz@android.com> | 2009-08-21 11:08:25 -0700 |
|---|---|---|
| committer | Doug Zongker <dougz@android.com> | 2009-08-21 11:08:25 -0700 |
| commit | 90b06ac786f859895ac503cf42759c2706205700 (patch) | |
| tree | 550b74a8743d2ba3378e2f8964bf1696417850eb /libmincrypt | |
| parent | a2f441b8c6781472deb5da0b27c3b5c81114299a (diff) | |
| download | system_core-90b06ac786f859895ac503cf42759c2706205700.zip system_core-90b06ac786f859895ac503cf42759c2706205700.tar.gz system_core-90b06ac786f859895ac503cf42759c2706205700.tar.bz2 | |
only use faster SHA-1 code on machines with good libc
Macs don't have byteswap.h or endian.h. Change conditionals to only
use the faster SHA-1 code on little-endian machines with byteswap.h.
Diffstat (limited to 'libmincrypt')
| -rw-r--r-- | libmincrypt/sha.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/libmincrypt/sha.c b/libmincrypt/sha.c index 33d1cb3..e089d79 100644 --- a/libmincrypt/sha.c +++ b/libmincrypt/sha.c @@ -25,13 +25,15 @@ ** ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include <byteswap.h> -#include <endian.h> -#include <memory.h> - #include "mincrypt/sha.h" -#if __BYTE_ORDER == __LITTLE_ENDIAN +// Some machines lack byteswap.h and endian.h. These have to use the +// slower code, even if they're little-endian. + +#if defined(HAVE_ENDIAN_H) && defined(HAVE_LITTLE_ENDIAN) + +#include <byteswap.h> +#include <memory.h> // This version is about 28% faster than the generic version below, // but assumes little-endianness. @@ -186,7 +188,7 @@ const uint8_t* SHA_final(SHA_CTX* ctx) { return ctx->buf.b; } -#else // __BYTE_ORDER == BIG_ENDIAN +#else // #if defined(HAVE_ENDIAN_H) && defined(HAVE_LITTLE_ENDIAN) #define rol(bits, value) (((value) << (bits)) | ((value) >> (32 - (bits)))) |
