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