1/*****************************************************************************
2
3Copyright (c) 2011, 2015, Oracle and/or its affiliates. All Rights Reserved.
4Copyright (c) 2016, MariaDB Corporation.
5
6This program is free software; you can redistribute it and/or modify it under
7the terms of the GNU General Public License as published by the Free Software
8Foundation; version 2 of the License.
9
10This program is distributed in the hope that it will be useful, but WITHOUT
11ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License along with
15this program; if not, write to the Free Software Foundation, Inc.,
1651 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
17
18*****************************************************************************/
19
20/**************************************************//**
21@file include/ut0crc32.h
22CRC32 implementation
23
24Created Aug 10, 2011 Vasil Dimov
25*******************************************************/
26
27#ifndef ut0crc32_h
28#define ut0crc32_h
29
30#include "univ.i"
31
32/********************************************************************//**
33Initializes the data structures used by ut_crc32*(). Does not do any
34allocations, would not hurt if called twice, but would be pointless. */
35void
36ut_crc32_init();
37/*===========*/
38
39/********************************************************************//**
40Calculates CRC32.
41@param ptr - data over which to calculate CRC32.
42@param len - data length in bytes.
43@return CRC32 (CRC-32C, using the GF(2) primitive polynomial 0x11EDC6F41,
44or 0x1EDC6F41 without the high-order bit) */
45typedef uint32_t (*ut_crc32_func_t)(const byte* ptr, ulint len);
46
47/** Pointer to CRC32 calculation function. */
48extern ut_crc32_func_t ut_crc32;
49
50/** CRC32 calculation function, which uses big-endian byte order
51when converting byte strings to integers internally. */
52extern uint32_t ut_crc32_legacy_big_endian(const byte* buf, ulint len);
53
54/** Text description of CRC32 implementation */
55extern const char* ut_crc32_implementation;
56
57#endif /* ut0crc32_h */
58