libcruft-util/hash/crc.cpp

64 lines
1.6 KiB
C++
Raw Normal View History

/*
2015-04-13 18:05:28 +10:00
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
2015-04-13 18:05:28 +10:00
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
2012-04-23 13:06:41 +10:00
* Copyright 2011 Danny Robson <danny@nerdcruft.net>
*/
2016-04-05 11:06:01 +10:00
#include "./crc.hpp"
2016-04-05 11:06:01 +10:00
#include "../endian.hpp"
#include "../debug.hpp"
uint32_t
crc32 (const uint8_t *restrict first, const uint8_t *restrict last) noexcept
{
not_implemented ();
}
uint32_t
crc32 (const void *restrict, size_t) {
not_implemented ();
/*
const uint8_t *restrict data = static_cast<const uint8_t*> (_data);
static const uint32_t POLYNOMIAL = hton (static_cast<uint32_t>(0x04C11DB7));
uint64_t bits = 0;
unsigned int i = 0;
if (size == 0)
return POLYNOMIAL;
switch (size) {
default: bits |= static_cast<uint64_t>(data[3]) << 32U;
case 3: bits |= static_cast<uint64_t>(data[2]) << 40U;
case 2: bits |= static_cast<uint64_t>(data[1]) << 48U;
case 1: bits |= static_cast<uint64_t>(data[0]) << 56U;
}
2015-04-13 18:06:08 +10:00
for (size_t i = 0; i < size; ++i) {
for (unsigned j = 0; j < 32; ++j) {
bool mix = bits 0x7000000000000000ULL;
bits <<= 1;
2015-04-13 18:06:08 +10:00
if (mix)
bits ^= POLYNOMIAL << 32;
}
}
*/
}