25#ifndef MY_CHECKSUM_INCLUDED
26#define MY_CHECKSUM_INCLUDED
43#ifdef HAVE_ARMV8_CRC32_INTRINSIC
50#ifdef HAVE_ARMV8_CRC32_INTRINSIC
51const bool auxv_at_hwcap = (getauxval(AT_HWCAP) & HWCAP_CRC32);
54MY_ATTRIBUTE((target(
"+crc")))
55inline std::uint32_t
IntegerCrc32(std::uint32_t crc, std::uint8_t b) {
56 return __crc32b(crc, b);
59MY_ATTRIBUTE((target(
"+crc")))
60inline std::uint32_t
IntegerCrc32(std::uint32_t crc, std::uint16_t h) {
61 return __crc32h(crc, h);
64MY_ATTRIBUTE((target(
"+crc")))
65inline std::uint32_t
IntegerCrc32(std::uint32_t crc, std::uint32_t w) {
66 return __crc32w(crc, w);
69MY_ATTRIBUTE((target(
"+crc")))
70inline std::uint32_t
IntegerCrc32(std::uint32_t crc, std::uint64_t d) {
71 return __crc32d(crc, d);
77 unsigned char buf[
sizeof(I)];
78 memcpy(
buf, &i,
sizeof(I));
80 crc = crc32_z(crc,
buf,
sizeof(I));
90 const unsigned char *plast =
buf + (len /
sizeof(PT)) *
sizeof(PT);
91 const unsigned char *
last =
buf + len;
92 for (;
buf < plast;
buf +=
sizeof(PT)) {
94 memcpy(&pv,
buf,
sizeof(PT));
119#ifdef HAVE_ARMV8_CRC32_INTRINSIC
120 if (mycrc32::auxv_at_hwcap)
121 return mycrc32::PunnedCrc32<std::uint64_t>(crc, pos,
length);
123 static_assert(std::is_convertible<uLong, ha_checksum>::value,
124 "uLong cannot be converted to ha_checksum");
125 assert(crc32_z(crc, pos,
length) <= std::numeric_limits<ha_checksum>::max());
126 return crc32_z(crc, pos,
length);
ha_checksum my_checksum(ha_checksum crc, const unsigned char *pos, size_t length)
Calculate a CRC32 checksum for a memoryblock.
Definition: my_checksum.h:117
std::uint32_t ha_checksum
Definition: my_checksum.h:106
Header for compiler-dependent features.
Definition: buf0block_hint.cc:30
bool length(const dd::Spatial_reference_system *srs, const Geometry *g1, double *length, bool *null) noexcept
Computes the length of linestrings and multilinestrings.
Definition: length.cc:76
Definition: my_checksum.h:49
std::uint32_t IntegerCrc32(std::uint32_t crc, I i)
Definition: my_checksum.h:76
std::uint32_t PunnedCrc32(std::uint32_t crc, const unsigned char *buf, size_t len)
Definition: my_checksum.h:87