summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config.h10
-rw-r--r--integer.cpp12
-rw-r--r--misc.h4
-rw-r--r--nbtheory.cpp2
4 files changed, 17 insertions, 11 deletions
diff --git a/config.h b/config.h
index d9b119a..d4f5cb8 100644
--- a/config.h
+++ b/config.h
@@ -108,9 +108,13 @@ typedef unsigned short word16;
# define W64LIT(x) x##ui64
#endif
-// defined this if your CPU is not 64-bit
-#if defined(WORD64_AVAILABLE) && !defined(__alpha)
-# define SLOW_WORD64
+#if defined(__alpha__) || defined(__ia64__) || defined(_ARCH_PPC64) || defined(__x86_64__) || defined(__mips64) || defined(__sparc_v9__) || defined(__sparcv9) || defined(__sparc_v8__) || defined(__sparcv8)
+# define CRYPTOPP_64BIT_CPU
+#endif
+
+// defined this if your CPU is not 64-bit to use alternative code that avoids word64
+#if defined(WORD64_AVAILABLE) && !defined(CRYPTOPP_64BIT_CPU)
+# define CRYPTOPP_SLOW_WORD64
#endif
// word should have the same size as your CPU registers
diff --git a/integer.cpp b/integer.cpp
index cdcc133..deb60f9 100644
--- a/integer.cpp
+++ b/integer.cpp
@@ -1703,18 +1703,20 @@ void PentiumOptimized::Multiply8(word* Z, const word* X, const word* Y)
);
}
-#elif defined(__GNUC__) && (defined(__alpha__) || defined(__ia64__) || defined(_ARCH_PPC64) || defined(__x86_64__) || defined(__mips64))
+#elif defined(__GNUC__) && defined(CRYPTOPP_64BIT_CPU)
#ifdef __alpha__
#define MUL64x64(a, b, c, d) c = a*b; __asm__("umulh %1,%2,%0" : "=r" (d) : "r" (a), "r" (b))
-#else defined(__ia64__)
+#elif defined(__ia64__)
#define MUL64x64(a, b, c, d) c = a*b; __asm__("xmpy.hu %0=%1,%2" : "=f" (d) : "f" (a), "f" (b))
-#else defined(_ARCH_PPC64)
+#elif defined(_ARCH_PPC64)
#define MUL64x64(a, b, c, d) c = a*b; __asm__("mulhdu %0,%1,%2" : "=r" (d) : "r" (a), "r" (b) : "cc")
-#else defined(__x86_64__)
+#elif defined(__x86_64__)
#define MUL64x64(a, b, c, d) __asm__("mulq %3" : "=d" (d), "=a" (c) : "a" (a), "rm" (b) : "cc")
-#else defined(__mips64)
+#elif defined(__mips64)
#define MUL64x64(a, b, c, d) __asm__("dmultu %2,%3" : "=h" (d), "=l" (c) : "r" (a), "r" (b))
+#elif defined(__sparc_v9__) || defined(__sparcv9) || defined(__sparc_v8__) || defined(__sparcv8)
+#define MUL64x64(a, b, c, d) __asm__("umul %2,%3,%1;rd %%y,%0" : "=r" (d), "=r" (c) : "r" (a), "r" (b))
#endif
class OptimizedFor64BitCPU : public Portable
diff --git a/misc.h b/misc.h
index 2418016..f6918b8 100644
--- a/misc.h
+++ b/misc.h
@@ -383,7 +383,7 @@ inline word32 ByteReverse(word32 value)
#ifdef WORD64_AVAILABLE
inline word64 ByteReverse(word64 value)
{
-#ifdef SLOW_WORD64
+#ifdef CRYPTOPP_SLOW_WORD64
return (word64(ByteReverse(word32(value))) << 32) | ByteReverse(word32(value>>32));
#else
value = ((value & W64LIT(0xFF00FF00FF00FF00)) >> 8) | ((value & W64LIT(0x00FF00FF00FF00FF)) << 8);
@@ -419,7 +419,7 @@ inline word32 BitReverse(word32 value)
#ifdef WORD64_AVAILABLE
inline word64 BitReverse(word64 value)
{
-#ifdef SLOW_WORD64
+#ifdef CRYPTOPP_SLOW_WORD64
return (word64(BitReverse(word32(value))) << 32) | BitReverse(word32(value>>32));
#else
value = ((value & W64LIT(0xAAAAAAAAAAAAAAAA)) >> 1) | ((value & W64LIT(0x5555555555555555)) << 1);
diff --git a/nbtheory.cpp b/nbtheory.cpp
index 2a517d7..ee015a4 100644
--- a/nbtheory.cpp
+++ b/nbtheory.cpp
@@ -34,7 +34,7 @@ std::vector<word> * NewPrimeTable()
if (j == testEntriesEnd)
{
primeTable.push_back(p);
- testEntriesEnd = STDMIN(54U, primeTable.size());
+ testEntriesEnd = STDMIN((size_t)54U, primeTable.size());
}
}