2011-11-04 16:56:25 +11:00
|
|
|
/*
|
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
|
2011-11-04 16:56:25 +11:00
|
|
|
*
|
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.
|
2011-11-04 16:56:25 +11:00
|
|
|
*
|
2012-04-23 13:06:41 +10:00
|
|
|
* Copyright 2011 Danny Robson <danny@nerdcruft.net>
|
2011-11-04 16:56:25 +11:00
|
|
|
*/
|
|
|
|
|
2016-04-05 11:06:01 +10:00
|
|
|
#include "./crc.hpp"
|
2011-11-04 16:56:25 +11:00
|
|
|
|
2016-04-05 11:06:01 +10:00
|
|
|
#include "../endian.hpp"
|
|
|
|
#include "../debug.hpp"
|
2011-11-04 16:56:25 +11:00
|
|
|
|
2016-06-17 15:46:11 +10:00
|
|
|
|
|
|
|
uint32_t
|
|
|
|
crc32 (const uint8_t *restrict first, const uint8_t *restrict last) noexcept
|
|
|
|
{
|
|
|
|
not_implemented ();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-11-04 16:56:25 +11:00
|
|
|
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
|
|
|
|
2011-11-04 16:56:25 +11: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)
|
2011-11-04 16:56:25 +11:00
|
|
|
bits ^= POLYNOMIAL << 32;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
}
|