"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "crc32c.c" between
memcached-1.6.8.tar.gz and memcached-1.6.9.tar.gz

About: memcached is a high-performance, distributed memory object caching system, generic in nature, but originally intended for use in speeding up dynamic web applications by alleviating database load.

crc32c.c  (memcached-1.6.8):crc32c.c  (memcached-1.6.9)
skipping to change at line 51 skipping to change at line 51
*/ */
#include <pthread.h> #include <pthread.h>
#include "crc32c.h" #include "crc32c.h"
crc_func crc32c; crc_func crc32c;
/* CRC-32C (iSCSI) polynomial in reversed bit order. */ /* CRC-32C (iSCSI) polynomial in reversed bit order. */
#define POLY 0x82f63b78 #define POLY 0x82f63b78
uint32_t crc32c_sw(uint32_t crc, void const *buf, size_t len);
uint32_t crc32c_sw_little(uint32_t crc, void const *buf, size_t len); uint32_t crc32c_sw_little(uint32_t crc, void const *buf, size_t len);
uint32_t crc32c_sw_big(uint32_t crc, void const *buf, size_t len); uint32_t crc32c_sw_big(uint32_t crc, void const *buf, size_t len);
#ifdef __x86_64__ #ifdef __x86_64__
/* Hardware CRC-32C for Intel and compatible processors. */ /* Hardware CRC-32C for Intel and compatible processors. */
/* Multiply a matrix times a vector over the Galois field of two elements, /* Multiply a matrix times a vector over the Galois field of two elements,
GF(2). Each element is a bit in an unsigned integer. mat must have at GF(2). Each element is a bit in an unsigned integer. mat must have at
least as many entries as the power of two for most significant one bit in least as many entries as the power of two for most significant one bit in
vec. */ vec. */
skipping to change at line 277 skipping to change at line 276
int sse42; int sse42;
SSE42(sse42); SSE42(sse42);
if (sse42) { if (sse42) {
crc32c = crc32c_hw; crc32c = crc32c_hw;
} else { } else {
crc32c = crc32c_sw; crc32c = crc32c_sw;
} }
} }
#else /* !__x86_64__ */ #elif defined(__aarch64__) && defined(__linux__)
#include <sys/auxv.h>
static inline uint32_t crc32cx(uint32_t crc, const uint64_t data)
{
asm(".arch_extension crc\n"
"crc32cx %w0, %w0, %x1" : "+r" (crc) : "r" (data));
return crc;
}
static inline uint32_t crc32cb(uint32_t crc, const uint8_t data)
{
asm(".arch_extension crc\n"
"crc32cb %w0, %w0, %w1" : "+r" (crc) : "r" (data));
return crc;
}
static uint32_t crc32c_hw(uint32_t crc, void const *buf, size_t len) {
crc = ~crc;
unsigned char const *next = buf;
while (((uintptr_t)next & 7) && len > 0) {
crc = crc32cb(crc, *(uint8_t *)next);
next++;
len--;
}
while (len >= 64) {
uint64_t *next8 = (uint64_t *)next;
crc = crc32cx(crc, next8[0]);
crc = crc32cx(crc, next8[1]);
crc = crc32cx(crc, next8[2]);
crc = crc32cx(crc, next8[3]);
crc = crc32cx(crc, next8[4]);
crc = crc32cx(crc, next8[5]);
crc = crc32cx(crc, next8[6]);
crc = crc32cx(crc, next8[7]);
next += 64;
len -= 64;
}
while (len >= 8) {
crc = crc32cx(crc, *(uint64_t *)next);
next += 8;
len -= 8;
}
while (len > 0) {
crc = crc32cb(crc, *(uint8_t *)next);
next++;
len--;
}
return ~crc;
}
void crc32c_init(void) {
uint64_t auxv = getauxval(AT_HWCAP);
crc32c = crc32c_sw;
if (auxv & HWCAP_CRC32)
crc32c = crc32c_hw;
}
#else /* !__x86_64__i && !__aarch64__ */
void crc32c_init(void) { void crc32c_init(void) {
crc32c = crc32c_sw; crc32c = crc32c_sw;
} }
#endif #endif
/* Construct table for software CRC-32C little-endian calculation. */ /* Construct table for software CRC-32C little-endian calculation. */
static pthread_once_t crc32c_once_little = PTHREAD_ONCE_INIT; static pthread_once_t crc32c_once_little = PTHREAD_ONCE_INIT;
static uint32_t crc32c_table_little[8][256]; static uint32_t crc32c_table_little[8][256];
static void crc32c_init_sw_little(void) { static void crc32c_init_sw_little(void) {
 End of changes. 3 change blocks. 
2 lines changed or deleted 63 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)