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".
pull/748/head
Jeffrey Walton 2018-11-18 11:57:33 -05:00
parent aae108d228
commit 59ba3b6aca
No known key found for this signature in database
GPG Key ID: B36AB348921B1838
1 changed files with 11 additions and 3 deletions

View File

@ -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