hash: make use of restrict and noexcept consistent

This commit is contained in:
Danny Robson 2016-06-17 16:06:46 +10:00
parent f88958d17d
commit 5e6155a51a
18 changed files with 28 additions and 28 deletions

View File

@ -24,7 +24,7 @@ static const unsigned MODULUS = 65521;
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
uint32_t uint32_t
util::hash::adler32 (const void* restrict _data, size_t _size) util::hash::adler32 (const void* restrict _data, size_t _size) noexcept
{ {
return adler32 ( return adler32 (
static_cast<const uint8_t*> (_data), static_cast<const uint8_t*> (_data),
@ -35,7 +35,7 @@ util::hash::adler32 (const void* restrict _data, size_t _size)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
uint32_t uint32_t
util::hash::adler32 (const uint8_t *first, const uint8_t *last) util::hash::adler32 (const uint8_t *restrict first, const uint8_t *restrict last) noexcept
{ {
return fletcher<32, MODULUS, 1, 0> (first, last - first); return fletcher<32, MODULUS, 1, 0> (first, last - first);
} }

View File

@ -21,8 +21,8 @@
#include <cstdlib> #include <cstdlib>
namespace util { namespace hash { namespace util { namespace hash {
uint32_t adler32 (const void* restrict, size_t); uint32_t adler32 (const void* restrict, size_t) noexcept;
uint32_t adler32 (const uint8_t *first, const uint8_t *last); uint32_t adler32 (const uint8_t *restrict first, const uint8_t *restrict last) noexcept;
} } } }
#endif #endif

View File

@ -24,7 +24,7 @@ uint16_t
util::hash::bsdsum ( util::hash::bsdsum (
const uint8_t *const restrict first, const uint8_t *const restrict first,
const uint8_t *const restrict last const uint8_t *const restrict last
) { ) noexcept {
CHECK_LE (first, last); CHECK_LE (first, last);
uint16_t accum = 0; uint16_t accum = 0;
@ -40,7 +40,7 @@ util::hash::bsdsum (
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
uint16_t uint16_t
util::hash::bsdsum (const void *restrict data, size_t size) util::hash::bsdsum (const void *restrict data, size_t size) noexcept
{ {
return bsdsum ( return bsdsum (
static_cast<const uint8_t*> (data), static_cast<const uint8_t*> (data),

View File

@ -21,8 +21,8 @@
#include <cstdlib> #include <cstdlib>
namespace util { namespace hash { namespace util { namespace hash {
uint16_t bsdsum (const void *restrict data, size_t bytes); uint16_t bsdsum (const void *restrict data, size_t bytes) noexcept;
uint16_t bsdsum (const uint8_t *restrict first, const uint8_t *restrict last); uint16_t bsdsum (const uint8_t *restrict first, const uint8_t *restrict last) noexcept;
} } } }
#endif #endif

View File

@ -34,7 +34,7 @@ util::hash::crc32 (
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
uint32_t uint32_t
util::hash::crc32 (const void *restrict, size_t) { util::hash::crc32 (const void *restrict, size_t) noexcept {
not_implemented (); not_implemented ();
/* /*

View File

@ -21,7 +21,7 @@
#include <cstdlib> #include <cstdlib>
namespace util { namespace hash { namespace util { namespace hash {
uint32_t crc32 (const void *restrict data, size_t bytes); uint32_t crc32 (const void *restrict data, size_t bytes) noexcept;
uint32_t crc32 (const uint8_t *restrict first, const uint8_t *restrict last) noexcept; uint32_t crc32 (const uint8_t *restrict first, const uint8_t *restrict last) noexcept;
} } } }
#endif #endif

View File

@ -83,7 +83,7 @@ MD2::update (const uint8_t *restrict first, const uint8_t *restrict last) noexce
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void void
MD2::update (const void *data, size_t size) MD2::update (const void *restrict data, size_t size) noexcept
{ {
update (static_cast<const uint8_t*> (data), size); update (static_cast<const uint8_t*> (data), size);
} }
@ -96,7 +96,7 @@ static const size_t M_LENGTH = 16;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void void
MD2::update (const uint8_t *data, size_t size) MD2::update (const uint8_t *restrict data, size_t size) noexcept
{ {
uint8_t *M = X + M_OFFSET; uint8_t *M = X + M_OFFSET;
size_t offset = m_total % M_LENGTH; size_t offset = m_total % M_LENGTH;

View File

@ -29,8 +29,8 @@ namespace util { namespace hash {
public: public:
MD2 (); MD2 ();
void update (const uint8_t *data, size_t len); void update (const uint8_t *restrict data, size_t len) noexcept;
void update (const void *data, size_t len); void update (const void *restrict data, size_t len) noexcept;
void update (const uint8_t *restrict first, const uint8_t *restrict last) noexcept; void update (const uint8_t *restrict first, const uint8_t *restrict last) noexcept;
void finish (void); void finish (void);

View File

@ -82,12 +82,12 @@ MD4::update (const uint8_t *restrict first, const uint8_t *restrict last) noexce
void void
MD4::update (const void *data, size_t size) MD4::update (const void *restrict data, size_t size) noexcept
{ update (static_cast<const uint8_t*> (data), size); } { update (static_cast<const uint8_t*> (data), size); }
void void
MD4::update (const uint8_t *data, size_t size) { MD4::update (const uint8_t *restrict data, size_t size) noexcept {
size_t offset = m_total % sizeof (Xb); size_t offset = m_total % sizeof (Xb);
size_t remain = sizeof (Xb) - offset; size_t remain = sizeof (Xb) - offset;

View File

@ -28,8 +28,8 @@ namespace util { namespace hash {
public: public:
MD4(); MD4();
void update (const void *data, size_t len); void update (const void *restrict data, size_t len) noexcept;
void update (const uint8_t *data, size_t len); void update (const uint8_t *restrict data, size_t len) noexcept;
void update (const uint8_t *restrict first, const uint8_t *restrict last) noexcept; void update (const uint8_t *restrict first, const uint8_t *restrict last) noexcept;
void finish (void); void finish (void);

View File

@ -112,12 +112,12 @@ MD5::update (const uint8_t *restrict first, const uint8_t *restrict last) noexce
void void
MD5::update (const void *data, size_t len) MD5::update (const void *restrict data, size_t len) noexcept
{ MD5::update (static_cast<const uint8_t*> (data), len); } { MD5::update (static_cast<const uint8_t*> (data), len); }
void void
MD5::update (const uint8_t *data, size_t size) { MD5::update (const uint8_t *restrict data, size_t size) noexcept {
size_t offset = m_total % sizeof (Xb); size_t offset = m_total % sizeof (Xb);
size_t remain = sizeof (Xb) - offset; size_t remain = sizeof (Xb) - offset;

View File

@ -31,8 +31,8 @@ namespace util { namespace hash {
public: public:
MD5(); MD5();
void update (const void *data, size_t len); void update (const void *restrict data, size_t len) noexcept;
void update (const uint8_t *data, size_t len); void update (const uint8_t *restrict data, size_t len) noexcept;
void update (const uint8_t *restrict first, const uint8_t *restrict last) noexcept; void update (const uint8_t *restrict first, const uint8_t *restrict last) noexcept;
void finish (void); void finish (void);

View File

@ -59,7 +59,7 @@ RIPEMD::update (const uint8_t *restrict first, const uint8_t *restrict last) noe
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void void
RIPEMD::update (const uint8_t *data, size_t len) { RIPEMD::update (const uint8_t *restrict data, size_t len) noexcept {
CHECK (data); CHECK (data);
size_t cursor = 0; size_t cursor = 0;

View File

@ -28,7 +28,7 @@ namespace util { namespace hash {
public: public:
RIPEMD(); RIPEMD();
void update (const uint8_t*, size_t); void update (const uint8_t *restrict, size_t) noexcept;
void update (const uint8_t *restrict first, const uint8_t *restrict last) noexcept; void update (const uint8_t *restrict first, const uint8_t *restrict last) noexcept;
digest_t digest (void) const; digest_t digest (void) const;

View File

@ -116,7 +116,7 @@ SHA1::update (const uint8_t *restrict first, const uint8_t *restrict last) noexc
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void void
SHA1::update (const uint8_t *data, size_t size) { SHA1::update (const uint8_t *restrict data, size_t size) noexcept {
CHECK_EQ (state, READY); CHECK_EQ (state, READY);
CHECK_GE (numeric_limits<decltype(total)>::max () - total, size); CHECK_GE (numeric_limits<decltype(total)>::max () - total, size);

View File

@ -34,7 +34,7 @@ namespace util { namespace hash {
public: public:
SHA1(); SHA1();
void update (const uint8_t *, size_t); void update (const uint8_t *restrict, size_t) noexcept;
void update (const uint8_t *restrict first, const uint8_t *restrict last) noexcept; void update (const uint8_t *restrict first, const uint8_t *restrict last) noexcept;
void finish (void); void finish (void);

View File

@ -181,7 +181,7 @@ SHA256::update (const uint8_t *restrict first, const uint8_t *restrict last) noe
void void
SHA256::update (const uint8_t *data, size_t length) { SHA256::update (const uint8_t *restrict data, size_t length) noexcept {
while (length) { while (length) {
size_t buffered = m_total % sizeof (M); size_t buffered = m_total % sizeof (M);
size_t chunk = std::min (sizeof (M) - buffered, length); size_t chunk = std::min (sizeof (M) - buffered, length);

View File

@ -29,7 +29,7 @@ namespace util { namespace hash {
public: public:
SHA256(); SHA256();
void update (const uint8_t *, size_t); void update (const uint8_t *restrict, size_t) noexcept;
void update (const uint8_t *restrict first, const uint8_t *restrict last) noexcept; void update (const uint8_t *restrict first, const uint8_t *restrict last) noexcept;
void finish (void); void finish (void);