summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwtc%google.com <devnull@localhost>2008-02-16 02:24:48 +0000
committerwtc%google.com <devnull@localhost>2008-02-16 02:24:48 +0000
commit40d3709f638d6bd8e9eda566376bb63019bdf850 (patch)
tree1fc1298af5b86c45ba75fdf63ca8e42a86138a88
parente007f1311dd8650c45624e1f610a5a10603215ec (diff)
downloadnss-hg-40d3709f638d6bd8e9eda566376bb63019bdf850.tar.gz
Bug 416508: Use Visual C++ intrinsic function _byteswap_ulong. r=nelson.
Modified files: sha512.c sha_fast.h
-rw-r--r--security/nss/lib/freebl/sha512.c7
-rw-r--r--security/nss/lib/freebl/sha_fast.h12
2 files changed, 14 insertions, 5 deletions
diff --git a/security/nss/lib/freebl/sha512.c b/security/nss/lib/freebl/sha512.c
index d239fc825..b01b643ad 100644
--- a/security/nss/lib/freebl/sha512.c
+++ b/security/nss/lib/freebl/sha512.c
@@ -93,7 +93,12 @@ static const PRUint32 H256[8] = {
0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19
};
-#if defined(_MSC_VER) && defined(_X86_)
+#if (_MSC_VER >= 1300)
+#include <stdlib.h>
+#pragma intrinsic(_byteswap_ulong)
+#define SHA_HTONL(x) _byteswap_ulong(x)
+#define BYTESWAP4(x) x = SHA_HTONL(x)
+#elif defined(_MSC_VER) && defined(_X86_)
#ifndef FORCEINLINE
#if (_MSC_VER >= 1200)
#define FORCEINLINE __forceinline
diff --git a/security/nss/lib/freebl/sha_fast.h b/security/nss/lib/freebl/sha_fast.h
index 6243471b0..cde706610 100644
--- a/security/nss/lib/freebl/sha_fast.h
+++ b/security/nss/lib/freebl/sha_fast.h
@@ -57,8 +57,12 @@ struct SHA1ContextStr {
SHA_HW_t H[22]; /* 5 state variables, 16 tmp values, 1 extra */
};
-#if defined(_MSC_VER) && defined(_X86_)
-#if defined(IS_LITTLE_ENDIAN)
+#if defined(_MSC_VER)
+#include <stdlib.h>
+#if (_MSC_VER >= 1300)
+#pragma intrinsic(_byteswap_ulong)
+#define SHA_HTONL(x) _byteswap_ulong(x)
+#elif defined(_X86_)
#ifndef FORCEINLINE
#if (_MSC_VER >= 1200)
#define FORCEINLINE __forceinline
@@ -78,12 +82,12 @@ swap4b(PRUint32 dwd)
}
#define SHA_HTONL(x) swap4b(x)
-#endif /* IS_LITTLE_ENDIAN */
+#endif /* _X86_ */
#pragma intrinsic (_lrotr, _lrotl)
#define SHA_ROTL(x,n) _lrotl(x,n)
#define SHA_ROTL_IS_DEFINED 1
-#endif /* _MSC_VER && _X86_ */
+#endif /* _MSC_VER */
#if defined(__GNUC__)
/* __x86_64__ and __x86_64 are defined by GCC on x86_64 CPUs */