mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-05-19 01:15:08 -04:00
crypto: implement md5, which now used by sprof
This commit is contained in:
parent
9cc6be4d57
commit
a14dc6ed89
9 changed files with 431 additions and 5 deletions
|
@ -256,7 +256,7 @@ namespace ams::util {
|
|||
}
|
||||
|
||||
template<typename T, T N, T D>
|
||||
constexpr ALWAYS_INLINE T ScaleByConstantFactor(const T V) {
|
||||
constexpr ALWAYS_INLINE T ScaleByConstantFactorUp(const T V) {
|
||||
/* Multiplying and dividing by large numerator/denominator can cause error to be introduced. */
|
||||
/* This algorithm multiples/divides in stages, so as to mitigate this (particularly with large denominator). */
|
||||
|
||||
|
@ -279,4 +279,20 @@ namespace ams::util {
|
|||
return (D * Quot_N * Quot_V) + (Quot_V * Rem_N) + (Rem_V * Quot_N) + rem_mult;
|
||||
}
|
||||
|
||||
template<std::integral T>
|
||||
constexpr ALWAYS_INLINE T RotateLeft(T v, int n) {
|
||||
using Unsigned = typename std::make_unsigned<T>::type;
|
||||
static_assert(sizeof(Unsigned) == sizeof(T));
|
||||
|
||||
return static_cast<T>(std::rotl<Unsigned>(static_cast<Unsigned>(v), n));
|
||||
}
|
||||
|
||||
template<std::integral T>
|
||||
constexpr ALWAYS_INLINE T RotateRight(T v, int n) {
|
||||
using Unsigned = typename std::make_unsigned<T>::type;
|
||||
static_assert(sizeof(Unsigned) == sizeof(T));
|
||||
|
||||
return static_cast<T>(std::rotr<Unsigned>(static_cast<Unsigned>(v), n));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue