26 #include <arpa/inet.h>
32 #define HT_F32_DO1(buf,i) \
33 sum1 += ((uint16_t)buf[i] << 8) | buf[i + 1]; sum2 += sum1
34 #define HT_F32_DO2(buf, i) HT_F32_DO1(buf, i); HT_F32_DO1(buf, i + 2);
35 #define HT_F32_DO4(buf, i) HT_F32_DO2(buf, i); HT_F32_DO2(buf, i + 4);
36 #define HT_F32_DO8(buf, i) HT_F32_DO4(buf, i); HT_F32_DO4(buf, i + 8);
37 #define HT_F32_DO16(buf, i) HT_F32_DO8(buf, i); HT_F32_DO8(buf, i + 16);
46 const uint8_t *data = (
const uint8_t *)data8;
47 uint32_t sum1 = 0xffff, sum2 = 0xffff;
48 size_t len = len8 / 2;
54 unsigned tlen = len > 360 ? 360 : len;
68 sum1 = (sum1 & 0xffff) + (sum1 >> 16);
69 sum2 = (sum2 & 0xffff) + (sum2 >> 16);
74 sum1 += ((uint16_t)*data) << 8;
76 sum1 = (sum1 & 0xffff) + (sum1 >> 16);
77 sum2 = (sum2 & 0xffff) + (sum2 >> 16);
81 sum1 = (sum1 & 0xffff) + (sum1 >> 16);
82 sum2 = (sum2 & 0xffff) + (sum2 >> 16);
83 return (sum2 << 16) | sum1;
#define HT_F32_DO1(buf, i)
#define HT_F32_DO16(buf, i)
uint32_t fletcher32(const void *data8, size_t len8)
Compute fletcher32 checksum for arbitary data.
Compatibility Macros for C/C++.
Implementation of checksum routines.