diff options
author | Jeffrey Walton <noloader@gmail.com> | 2018-11-18 11:57:33 -0500 |
---|---|---|
committer | Jeffrey Walton <noloader@gmail.com> | 2018-11-18 11:57:33 -0500 |
commit | 59ba3b6aca10b7136279038bbcd21f271f9a677f (patch) | |
tree | 23b306d0760f42f0e45bbc6e82e8dd74bfa1e8f0 /blake2.cpp | |
parent | aae108d2284d42a27c6e19ba6f4d728167db8c35 (diff) | |
download | cryptopp-git-59ba3b6aca10b7136279038bbcd21f271f9a677f.tar.gz |
Switch between POWER7 and POWER4 (GH #656)
This is kind of tricky. We automatically drop from POWER7 to POWER4 if 7 is not available. However, if POWER7 is available the runtime test checks for HasAltivec(), and not HasPower7(), if the drop does not occur.
All of this goodness is happening on an old Apple G4 laptop with Gentoo. It is a "new toolchain on old hardware".
Diffstat (limited to 'blake2.cpp')
-rw-r--r-- | blake2.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
@@ -163,6 +163,8 @@ extern void BLAKE2_Compress64_NEON(const byte* input, BLAKE2b_State& state); #endif
#if CRYPTOPP_ALTIVEC_AVAILABLE
+// BLAKE2_Compress32_POWER7 may be compiled with either -mcpu=power7 or
+// -mcpu=power4. The makefile drops to POWER4 if POWER7 is not available.
extern void BLAKE2_Compress32_POWER7(const byte* input, BLAKE2s_State& state);
#endif
@@ -390,8 +392,7 @@ std::string BLAKE2s::AlgorithmProvider() const #if (CRYPTOPP_POWER7_AVAILABLE)
if (HasPower7())
return "Power7";
-#endif
-#if (CRYPTOPP_ALTIVEC_AVAILABLE)
+#elif (CRYPTOPP_ALTIVEC_AVAILABLE)
if (HasAltivec())
return "Altivec";
#endif
@@ -666,9 +667,16 @@ void BLAKE2s::Compress(const byte *input) return BLAKE2_Compress32_NEON(input, *m_state.data());
}
#endif
-#if CRYPTOPP_ALTIVEC_AVAILABLE
+#if CRYPTOPP_POWER7_AVAILABLE
+ if(HasPower7())
+ {
+ // BLAKE2_Compress32_POWER7 compiled with -mcpu=power7 and -DCRYPTOPP_POWER7_AVAILABLE
+ return BLAKE2_Compress32_POWER7(input, *m_state.data());
+ }
+#elif CRYPTOPP_ALTIVEC_AVAILABLE
if(HasAltivec())
{
+ // BLAKE2_Compress32_POWER7 compiled with -mcpu=power4 and -DCRYPTOPP_ALTIVEC_AVAILABLE
return BLAKE2_Compress32_POWER7(input, *m_state.data());
}
#endif
|