diff options
author | Jeffrey Walton <noloader@gmail.com> | 2018-11-27 02:54:26 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-27 02:54:26 -0500 |
commit | 3db34abf2f9ec9c25b1140955fced60c8d40394c (patch) | |
tree | 96fb730bea5aeb85c6040c367fb5a5c800c4585b /cpu.h | |
parent | 1966d13617b30e63068b056be90c75f37e549339 (diff) | |
download | cryptopp-git-3db34abf2f9ec9c25b1140955fced60c8d40394c.tar.gz |
Add Power9 Random Number Generator support (GH #747, PR #748)
Diffstat (limited to 'cpu.h')
-rw-r--r-- | cpu.h | 50 |
1 files changed, 43 insertions, 7 deletions
@@ -591,10 +591,12 @@ extern bool g_PowerpcDetectionDone; extern bool g_hasAltivec;
extern bool g_hasPower7;
extern bool g_hasPower8;
+extern bool g_hasPower9;
extern bool g_hasAES;
extern bool g_hasPMULL;
extern bool g_hasSHA256;
extern bool g_hasSHA512;
+extern bool g_hasDARN;
extern word32 g_cacheLineSize;
void CRYPTOPP_API DetectPowerpcFeatures();
#endif // CRYPTOPP_DOXYGEN_PROCESSING
@@ -608,7 +610,7 @@ void CRYPTOPP_API DetectPowerpcFeatures(); /// \details Runtime support requires compile time support. When compiling with GCC, you may
/// need to compile with <tt>-mcpu=power4</tt>; while IBM XL C/C++ compilers require
/// <tt>-qarch=pwr6 -qaltivec</tt>. Also see PowerPC's <tt>_ALTIVEC_</tt> preprocessor macro.
-/// \details Atilvec was first available on Power4 platforms. However Crypto++ releies heavily
+/// \details Atilvec was first available in the early 2000's. However Crypto++ releies heavily
/// on unaligned loads and stores which is a Power7 feature. If the platform lacks Power7
/// extensions, then the GNUmakefile sets <tt>-DCRYPTOPP_DISABLE_POWER7</tt>.
/// \note This function is only available on PowerPC and PowerPC-64 platforms
@@ -619,13 +621,13 @@ inline bool HasAltivec() return g_hasAltivec;
}
-/// \brief Determine if a PowerPC processor has Power8 available
-/// \returns true if the hardware is capable of Power8 at runtime, false otherwise.
+/// \brief Determine if a PowerPC processor has Power7 available
+/// \returns true if the hardware is capable of Power7 at runtime, false otherwise.
/// \details Altivec instructions are available under most modern PowerPCs.
/// \details Runtime support requires compile time support. When compiling with GCC, you may
-/// need to compile with <tt>-mcpu=power8</tt>; while IBM XL C/C++ compilers require
-/// <tt>-qarch=pwr8 -qaltivec</tt>. Also see PowerPC's <tt>_ALTIVEC_</tt> preprocessor macro.
-/// \details Atilvec was first available on Power4 platforms. However Crypto++ releies heavily
+/// need to compile with <tt>-mcpu=power7</tt>; while IBM XL C/C++ compilers require
+/// <tt>-qarch=pwr7 -qaltivec</tt>. Also see PowerPC's <tt>_ALTIVEC_</tt> preprocessor macro.
+/// \details Atilvec was first available in the early 2000's. However Crypto++ releies heavily
/// on unaligned loads and stores which is a Power7 feature. If the platform lacks Power7
/// extensions, then the GNUmakefile sets <tt>-DCRYPTOPP_DISABLE_POWER7</tt>.
/// \note This function is only available on PowerPC and PowerPC-64 platforms
@@ -642,7 +644,7 @@ inline bool HasPower7() /// \details Runtime support requires compile time support. When compiling with GCC, you may
/// need to compile with <tt>-mcpu=power8</tt>; while IBM XL C/C++ compilers require
/// <tt>-qarch=pwr8 -qaltivec</tt>. Also see PowerPC's <tt>_ALTIVEC_</tt> preprocessor macro.
-/// \details Atilvec was first available on Power4 platforms. However Crypto++ releies heavily
+/// \details Atilvec was first available in the early 2000's. However Crypto++ releies heavily
/// on unaligned loads and stores which is a Power7 feature. If the platform lacks Power7
/// extensions, then the GNUmakefile sets <tt>-DCRYPTOPP_DISABLE_POWER7</tt>.
/// \note This function is only available on PowerPC and PowerPC-64 platforms
@@ -653,6 +655,23 @@ inline bool HasPower8() return g_hasPower8;
}
+/// \brief Determine if a PowerPC processor has Power9 available
+/// \returns true if the hardware is capable of Power9 at runtime, false otherwise.
+/// \details Altivec instructions are available under most modern PowerPCs.
+/// \details Runtime support requires compile time support. When compiling with GCC, you may
+/// need to compile with <tt>-mcpu=power9</tt>; while IBM XL C/C++ compilers require
+/// <tt>-qarch=pwr9 -qaltivec</tt>. Also see PowerPC's <tt>_ALTIVEC_</tt> preprocessor macro.
+/// \details Atilvec was first available in the early 2000's. However Crypto++ releies heavily
+/// on unaligned loads and stores which is a Power7 feature. If the platform lacks Power7
+/// extensions, then the GNUmakefile sets <tt>-DCRYPTOPP_DISABLE_POWER7</tt>.
+/// \note This function is only available on PowerPC and PowerPC-64 platforms
+inline bool HasPower9()
+{
+ if (!g_PowerpcDetectionDone)
+ DetectPowerpcFeatures();
+ return g_hasPower9;
+}
+
/// \brief Determine if a PowerPC processor has AES available
/// \returns true if the hardware is capable of AES at runtime, false otherwise.
/// \details AES is part of the in-crypto extensions on Power8 and Power9.
@@ -709,6 +728,23 @@ inline bool HasSHA512() return g_hasSHA512;
}
+/// \brief Determine if a PowerPC processor has DARN available
+/// \returns true if the hardware is capable of DARN at runtime, false otherwise.
+/// \details Altivec instructions are available under most modern PowerPCs.
+/// \details Runtime support requires compile time support. When compiling with GCC, you may
+/// need to compile with <tt>-mcpu=power9</tt>; while IBM XL C/C++ compilers require
+/// <tt>-qarch=pwr9 -qaltivec</tt>. Also see PowerPC's <tt>_ALTIVEC_</tt> preprocessor macro.
+/// \details Atilvec was first available in the early 2000's. However Crypto++ relies heavily
+/// on unaligned loads and stores which is a Power7 feature. If the platform lacks Power7
+/// extensions, then the GNUmakefile sets <tt>-DCRYPTOPP_DISABLE_POWER7</tt>.
+/// \note This function is only available on PowerPC and PowerPC-64 platforms
+inline bool HasDARN()
+{
+ if (!g_PowerpcDetectionDone)
+ DetectPowerpcFeatures();
+ return g_hasDARN;
+}
+
/// \brief Provides the cache line size
/// \returns lower bound on the size of a cache line in bytes, if available
/// \details GetCacheLineSize() returns the lower bound on the size of a cache line, if it
|