MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ut0crc32.cc File Reference
#include "univ.i"
#include "ut0crc32.h"
#include <string.h>
Include dependency graph for ut0crc32.cc:

Go to the source code of this file.

Macros

#define ut_crc32_slice8_byte
#define ut_crc32_slice8_quadword

Functions

UNIV_INLINE ib_uint32_t ut_crc32_sse42 (const byte *buf, ulint len)
UNIV_INLINE ib_uint32_t ut_crc32_slice8 (const byte *buf, ulint len)
UNIV_INTERN void ut_crc32_init ()

Variables

ib_ut_crc32_t ut_crc32
UNIV_INTERN bool ut_crc32_sse2_enabled = false

Detailed Description

CRC32 implementation from Facebook, based on the zlib implementation.

Created Aug 8, 2011, Vasil Dimov, based on mysys/my_crc32.c and mysys/my_perf.c, contributed by Facebook under the following license.

Definition in file ut0crc32.cc.

Macro Definition Documentation

#define ut_crc32_slice8_byte
Value:
crc = (crc >> 8) ^ ut_crc32_slice8_table[0][(crc ^ *buf++) & 0xFF]; \
len--

Definition at line 219 of file ut0crc32.cc.

#define ut_crc32_slice8_quadword
Value:
crc ^= *(ib_uint64_t*) buf; \
crc = ut_crc32_slice8_table[7][(crc ) & 0xFF] ^ \
ut_crc32_slice8_table[6][(crc >> 8) & 0xFF] ^ \
ut_crc32_slice8_table[5][(crc >> 16) & 0xFF] ^ \
ut_crc32_slice8_table[4][(crc >> 24) & 0xFF] ^ \
ut_crc32_slice8_table[3][(crc >> 32) & 0xFF] ^ \
ut_crc32_slice8_table[2][(crc >> 40) & 0xFF] ^ \
ut_crc32_slice8_table[1][(crc >> 48) & 0xFF] ^ \
ut_crc32_slice8_table[0][(crc >> 56)]; \
len -= 8, buf += 8

Definition at line 223 of file ut0crc32.cc.

Function Documentation

UNIV_INTERN void ut_crc32_init ( )

Initializes the data structures used by ut_crc32(). Does not do any allocations, would not hurt if called twice, but would be pointless.

Definition at line 276 of file ut0crc32.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INLINE ib_uint32_t ut_crc32_slice8 ( const byte *  buf,
ulint  len 
)

Calculates CRC32 manually.

Returns
CRC-32C (polynomial 0x11EDC6F41)
Parameters
bufin: data over which to calculate CRC32
lenin: data length

Definition at line 240 of file ut0crc32.cc.

Here is the caller graph for this function:

UNIV_INLINE ib_uint32_t ut_crc32_sse42 ( const byte *  buf,
ulint  len 
)

Calculates CRC32 using CPU instructions.

Returns
CRC-32C (polynomial 0x11EDC6F41)
Parameters
bufin: data over which to calculate CRC32
lenin: data length

Definition at line 182 of file ut0crc32.cc.

Here is the caller graph for this function: