24#ifndef MY_CHECKSUM_INCLUDED
25#define MY_CHECKSUM_INCLUDED
42#ifdef HAVE_ARMV8_CRC32_INTRINSIC
49#ifdef HAVE_ARMV8_CRC32_INTRINSIC
50const bool auxv_at_hwcap = (getauxval(AT_HWCAP) & HWCAP_CRC32);
53MY_ATTRIBUTE((target(
"+crc")))
54inline std::uint32_t
IntegerCrc32(std::uint32_t crc, std::uint8_t b) {
55 return __crc32b(crc, b);
58MY_ATTRIBUTE((target(
"+crc")))
59inline std::uint32_t
IntegerCrc32(std::uint32_t crc, std::uint16_t h) {
60 return __crc32h(crc, h);
63MY_ATTRIBUTE((target(
"+crc")))
64inline std::uint32_t
IntegerCrc32(std::uint32_t crc, std::uint32_t w) {
65 return __crc32w(crc, w);
68MY_ATTRIBUTE((target(
"+crc")))
69inline std::uint32_t
IntegerCrc32(std::uint32_t crc, std::uint64_t d) {
70 return __crc32d(crc, d);
76 unsigned char buf[
sizeof(I)];
77 memcpy(
buf, &i,
sizeof(I));
79 crc = crc32_z(crc,
buf,
sizeof(I));
89 const unsigned char *plast =
buf + (len /
sizeof(PT)) *
sizeof(PT);
90 const unsigned char *
last =
buf + len;
91 for (;
buf < plast;
buf +=
sizeof(PT)) {
93 memcpy(&pv,
buf,
sizeof(PT));
118#ifdef HAVE_ARMV8_CRC32_INTRINSIC
119 if (mycrc32::auxv_at_hwcap)
120 return mycrc32::PunnedCrc32<std::uint64_t>(crc, pos,
length);
122 static_assert(std::is_convertible<uLong, ha_checksum>::value,
123 "uLong cannot be converted to ha_checksum");
124 assert(crc32_z(crc, pos,
length) <= std::numeric_limits<ha_checksum>::max());
125 return crc32_z(crc, pos,
length);
static char buf[MAX_BUF]
Definition: conf_to_src.cc:72
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:116
std::uint32_t ha_checksum
Definition: my_checksum.h:105
Header for compiler-dependent features.
Definition: buf0block_hint.cc:29
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:75
Definition: my_checksum.h:48
std::uint32_t IntegerCrc32(std::uint32_t crc, I i)
Definition: my_checksum.h:75
std::uint32_t PunnedCrc32(std::uint32_t crc, const unsigned char *buf, size_t len)
Definition: my_checksum.h:86