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
util::hash::adler32 (const void* restrict _data, size_t _size)
util::hash::adler32 (const void* restrict _data, size_t _size) noexcept
{
return adler32 (
static_cast<const uint8_t*> (_data),
@ -35,7 +35,7 @@ util::hash::adler32 (const void* restrict _data, size_t _size)
//-----------------------------------------------------------------------------
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);
}

View File

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

View File

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

View File

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

View File

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

View File

@ -21,7 +21,7 @@
#include <cstdlib>
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;
} }
#endif

View File

@ -83,7 +83,7 @@ MD2::update (const uint8_t *restrict first, const uint8_t *restrict last) noexce
//-----------------------------------------------------------------------------
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);
}
@ -96,7 +96,7 @@ static const size_t M_LENGTH = 16;
//-----------------------------------------------------------------------------
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;
size_t offset = m_total % M_LENGTH;

View File

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

View File

@ -82,12 +82,12 @@ MD4::update (const uint8_t *restrict first, const uint8_t *restrict last) noexce
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); }
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 remain = sizeof (Xb) - offset;

View File

@ -28,8 +28,8 @@ namespace util { namespace hash {
public:
MD4();
void update (const void *data, size_t len);
void update (const uint8_t *data, size_t len);
void update (const void *restrict data, size_t len) noexcept;
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 finish (void);

View File

@ -112,12 +112,12 @@ MD5::update (const uint8_t *restrict first, const uint8_t *restrict last) noexce
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); }
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 remain = sizeof (Xb) - offset;

View File

@ -31,8 +31,8 @@ namespace util { namespace hash {
public:
MD5();
void update (const void *data, size_t len);
void update (const uint8_t *data, size_t len);
void update (const void *restrict data, size_t len) noexcept;
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 finish (void);

View File

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

View File

@ -28,7 +28,7 @@ namespace util { namespace hash {
public:
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;
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
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_GE (numeric_limits<decltype(total)>::max () - total, size);

View File

@ -34,7 +34,7 @@ namespace util { namespace hash {
public:
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 finish (void);

View File

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

View File

@ -29,7 +29,7 @@ namespace util { namespace hash {
public:
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 finish (void);