1 /***************************************************************************** 2 3 Copyright (c) 2011, 2021, Oracle and/or its affiliates. 4 5 This program is free software; you can redistribute it and/or modify 6 it under the terms of the GNU General Public License, version 2.0, 7 as published by the Free Software Foundation. 8 9 This program is also distributed with certain software (including 10 but not limited to OpenSSL) that is licensed under separate terms, 11 as designated in a particular file or component or in included license 12 documentation. The authors of MySQL hereby grant you an additional 13 permission to link the program and your derivative works with the 14 separately licensed software that they have included with MySQL. 15 16 This program is distributed in the hope that it will be useful, 17 but WITHOUT ANY WARRANTY; without even the implied warranty of 18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 GNU General Public License, version 2.0, for more details. 20 21 You should have received a copy of the GNU General Public License along with 22 this program; if not, write to the Free Software Foundation, Inc., 23 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA 24 25 *****************************************************************************/ 26 27 /**************************************************//** 28 @file include/ut0crc32.h 29 CRC32 implementation 30 31 Created Aug 10, 2011 Vasil Dimov 32 *******************************************************/ 33 34 #ifndef ut0crc32_h 35 #define ut0crc32_h 36 37 #include "univ.i" 38 39 /********************************************************************//** 40 Initializes the data structures used by ut_crc32*(). Does not do any 41 allocations, would not hurt if called twice, but would be pointless. */ 42 void 43 ut_crc32_init(); 44 /*===========*/ 45 46 /********************************************************************//** 47 Calculates CRC32. 48 @param ptr - data over which to calculate CRC32. 49 @param len - data length in bytes. 50 @return CRC32 (CRC-32C, using the GF(2) primitive polynomial 0x11EDC6F41, 51 or 0x1EDC6F41 without the high-order bit) */ 52 typedef uint32_t (*ut_crc32_func_t)(const byte* ptr, ulint len); 53 54 /** Pointer to CRC32 calculation function. */ 55 extern ut_crc32_func_t ut_crc32; 56 57 /** Pointer to CRC32 calculation function, which uses big-endian byte order 58 when converting byte strings to integers internally. */ 59 extern ut_crc32_func_t ut_crc32_legacy_big_endian; 60 61 /** Pointer to CRC32-byte-by-byte calculation function (byte order agnostic, 62 but very slow). */ 63 extern ut_crc32_func_t ut_crc32_byte_by_byte; 64 65 /** Flag that tells whether the CPU supports CRC32 or not */ 66 extern bool ut_crc32_sse2_enabled; 67 68 #endif /* ut0crc32_h */ 69