Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-15 09:01:39

0001 /**********************************************************************
0002   Copyright(c) 2011-2023 Intel Corporation All rights reserved.
0003 
0004   Redistribution and use in source and binary forms, with or without
0005   modification, are permitted provided that the following conditions
0006   are met:
0007     * Redistributions of source code must retain the above copyright
0008       notice, this list of conditions and the following disclaimer.
0009     * Redistributions in binary form must reproduce the above copyright
0010       notice, this list of conditions and the following disclaimer in
0011       the documentation and/or other materials provided with the
0012       distribution.
0013     * Neither the name of Intel Corporation nor the names of its
0014       contributors may be used to endorse or promote products derived
0015       from this software without specific prior written permission.
0016 
0017   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
0018   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
0019   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
0020   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
0021   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
0022   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
0023   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
0024   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
0025   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
0026   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
0027   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0028 **********************************************************************/
0029 
0030 /**
0031  *  @file  crc64.h
0032  *  @brief CRC64 functions.
0033  */
0034 
0035 #ifndef _CRC64_H_
0036 #define _CRC64_H_
0037 
0038 #include <stdint.h>
0039 
0040 #ifdef __cplusplus
0041 extern "C" {
0042 #endif
0043 
0044 /* Multi-binary functions */
0045 
0046 /**
0047  * @brief Generate CRC from ECMA-182 standard in reflected format, runs
0048  * appropriate version.
0049  *
0050  * This function determines what instruction sets are enabled and
0051  * selects the appropriate version at runtime.
0052  * @returns 64 bit CRC
0053  */
0054 uint64_t
0055 crc64_ecma_refl(uint64_t init_crc,        //!< initial CRC value, 64 bits
0056                 const unsigned char *buf, //!< buffer to calculate CRC on
0057                 uint64_t len              //!< buffer length in bytes (64-bit data)
0058 );
0059 
0060 /**
0061  * @brief Generate CRC from ECMA-182 standard in normal format, runs
0062  * appropriate version.
0063  *
0064  * This function determines what instruction sets are enabled and
0065  * selects the appropriate version at runtime.
0066  * @returns 64 bit CRC
0067  */
0068 uint64_t
0069 crc64_ecma_norm(uint64_t init_crc,        //!< initial CRC value, 64 bits
0070                 const unsigned char *buf, //!< buffer to calculate CRC on
0071                 uint64_t len              //!< buffer length in bytes (64-bit data)
0072 );
0073 
0074 /**
0075  * @brief Generate CRC from ISO standard in reflected format, runs
0076  * appropriate version.
0077  *
0078  * This function determines what instruction sets are enabled and
0079  * selects the appropriate version at runtime.
0080  * @returns 64 bit CRC
0081  */
0082 uint64_t
0083 crc64_iso_refl(uint64_t init_crc,        //!< initial CRC value, 64 bits
0084                const unsigned char *buf, //!< buffer to calculate CRC on
0085                uint64_t len              //!< buffer length in bytes (64-bit data)
0086 );
0087 
0088 /**
0089  * @brief Generate CRC from ISO standard in normal format, runs
0090  * appropriate version.
0091  *
0092  * This function determines what instruction sets are enabled and
0093  * selects the appropriate version at runtime.
0094  * @returns 64 bit CRC
0095  */
0096 uint64_t
0097 crc64_iso_norm(uint64_t init_crc,        //!< initial CRC value, 64 bits
0098                const unsigned char *buf, //!< buffer to calculate CRC on
0099                uint64_t len              //!< buffer length in bytes (64-bit data)
0100 );
0101 
0102 /**
0103  * @brief Generate CRC from "Jones" coefficients in reflected format, runs
0104  * appropriate version.
0105  *
0106  * This function determines what instruction sets are enabled and
0107  * selects the appropriate version at runtime.
0108  * @returns 64 bit CRC
0109  */
0110 uint64_t
0111 crc64_jones_refl(uint64_t init_crc,        //!< initial CRC value, 64 bits
0112                  const unsigned char *buf, //!< buffer to calculate CRC on
0113                  uint64_t len              //!< buffer length in bytes (64-bit data)
0114 );
0115 
0116 /**
0117  * @brief Generate CRC from "Jones" coefficients in normal format, runs
0118  * appropriate version.
0119  *
0120  * This function determines what instruction sets are enabled and
0121  * selects the appropriate version at runtime.
0122  * @returns 64 bit CRC
0123  */
0124 uint64_t
0125 crc64_jones_norm(uint64_t init_crc,        //!< initial CRC value, 64 bits
0126                  const unsigned char *buf, //!< buffer to calculate CRC on
0127                  uint64_t len              //!< buffer length in bytes (64-bit data)
0128 );
0129 
0130 /**
0131  * @brief Generate CRC from "Rocksoft" coefficients in reflected format, runs
0132  * appropriate version.
0133  *
0134  * This function determines what instruction sets are enabled and
0135  * selects the appropriate version at runtime.
0136  * @returns 64 bit CRC
0137  */
0138 uint64_t
0139 crc64_rocksoft_refl(uint64_t init_crc,        //!< initial CRC value, 64 bits
0140                     const unsigned char *buf, //!< buffer to calculate CRC on
0141                     uint64_t len              //!< buffer length in bytes (64-bit data)
0142 );
0143 
0144 /**
0145  * @brief Generate CRC from "Rocksoft" coefficients in normal format, runs
0146  * appropriate version.
0147  *
0148  * This function determines what instruction sets are enabled and
0149  * selects the appropriate version at runtime.
0150  * @returns 64 bit CRC
0151  */
0152 uint64_t
0153 crc64_rocksoft_norm(uint64_t init_crc,        //!< initial CRC value, 64 bits
0154                     const unsigned char *buf, //!< buffer to calculate CRC on
0155                     uint64_t len              //!< buffer length in bytes (64-bit data)
0156 );
0157 
0158 /* Arch specific versions */
0159 
0160 /**
0161  * @brief Generate CRC from ECMA-182 standard in reflected format.
0162  * @requires SSE3, CLMUL
0163  *
0164  * @returns 64 bit CRC
0165  */
0166 
0167 uint64_t
0168 crc64_ecma_refl_by8(uint64_t init_crc,        //!< initial CRC value, 64 bits
0169                     const unsigned char *buf, //!< buffer to calculate CRC on
0170                     uint64_t len              //!< buffer length in bytes (64-bit data)
0171 );
0172 
0173 /**
0174  * @brief Generate CRC from ECMA-182 standard in normal format.
0175  * @requires SSE3, CLMUL
0176  *
0177  * @returns 64 bit CRC
0178  */
0179 
0180 uint64_t
0181 crc64_ecma_norm_by8(uint64_t init_crc,        //!< initial CRC value, 64 bits
0182                     const unsigned char *buf, //!< buffer to calculate CRC on
0183                     uint64_t len              //!< buffer length in bytes (64-bit data)
0184 );
0185 
0186 /**
0187  * @brief Generate CRC from ECMA-182 standard in reflected format, runs baseline version
0188  * @returns 64 bit CRC
0189  */
0190 uint64_t
0191 crc64_ecma_refl_base(uint64_t init_crc,        //!< initial CRC value, 64 bits
0192                      const unsigned char *buf, //!< buffer to calculate CRC on
0193                      uint64_t len              //!< buffer length in bytes (64-bit data)
0194 );
0195 
0196 /**
0197  * @brief Generate CRC from ECMA-182 standard in normal format, runs baseline version
0198  * @returns 64 bit CRC
0199  */
0200 uint64_t
0201 crc64_ecma_norm_base(uint64_t init_crc,        //!< initial CRC value, 64 bits
0202                      const unsigned char *buf, //!< buffer to calculate CRC on
0203                      uint64_t len              //!< buffer length in bytes (64-bit data)
0204 );
0205 
0206 /**
0207  * @brief Generate CRC from ISO standard in reflected format.
0208  * @requires SSE3, CLMUL
0209  *
0210  * @returns 64 bit CRC
0211  */
0212 
0213 uint64_t
0214 crc64_iso_refl_by8(uint64_t init_crc,        //!< initial CRC value, 64 bits
0215                    const unsigned char *buf, //!< buffer to calculate CRC on
0216                    uint64_t len              //!< buffer length in bytes (64-bit data)
0217 );
0218 
0219 /**
0220  * @brief Generate CRC from ISO standard in normal format.
0221  * @requires SSE3, CLMUL
0222  *
0223  * @returns 64 bit CRC
0224  */
0225 
0226 uint64_t
0227 crc64_iso_norm_by8(uint64_t init_crc,        //!< initial CRC value, 64 bits
0228                    const unsigned char *buf, //!< buffer to calculate CRC on
0229                    uint64_t len              //!< buffer length in bytes (64-bit data)
0230 );
0231 
0232 /**
0233  * @brief Generate CRC from ISO standard in reflected format, runs baseline version
0234  * @returns 64 bit CRC
0235  */
0236 uint64_t
0237 crc64_iso_refl_base(uint64_t init_crc,        //!< initial CRC value, 64 bits
0238                     const unsigned char *buf, //!< buffer to calculate CRC on
0239                     uint64_t len              //!< buffer length in bytes (64-bit data)
0240 );
0241 
0242 /**
0243  * @brief Generate CRC from ISO standard in normal format, runs baseline version
0244  * @returns 64 bit CRC
0245  */
0246 uint64_t
0247 crc64_iso_norm_base(uint64_t init_crc,        //!< initial CRC value, 64 bits
0248                     const unsigned char *buf, //!< buffer to calculate CRC on
0249                     uint64_t len              //!< buffer length in bytes (64-bit data)
0250 );
0251 
0252 /**
0253  * @brief Generate CRC from "Jones" coefficients in reflected format.
0254  * @requires SSE3, CLMUL
0255  *
0256  * @returns 64 bit CRC
0257  */
0258 
0259 uint64_t
0260 crc64_jones_refl_by8(uint64_t init_crc,        //!< initial CRC value, 64 bits
0261                      const unsigned char *buf, //!< buffer to calculate CRC on
0262                      uint64_t len              //!< buffer length in bytes (64-bit data)
0263 );
0264 
0265 /**
0266  * @brief Generate CRC from "Jones" coefficients in normal format.
0267  * @requires SSE3, CLMUL
0268  *
0269  * @returns 64 bit CRC
0270  */
0271 
0272 uint64_t
0273 crc64_jones_norm_by8(uint64_t init_crc,        //!< initial CRC value, 64 bits
0274                      const unsigned char *buf, //!< buffer to calculate CRC on
0275                      uint64_t len              //!< buffer length in bytes (64-bit data)
0276 );
0277 
0278 /**
0279  * @brief Generate CRC from "Jones" coefficients in reflected format, runs baseline version
0280  * @returns 64 bit CRC
0281  */
0282 uint64_t
0283 crc64_jones_refl_base(uint64_t init_crc,        //!< initial CRC value, 64 bits
0284                       const unsigned char *buf, //!< buffer to calculate CRC on
0285                       uint64_t len              //!< buffer length in bytes (64-bit data)
0286 );
0287 
0288 /**
0289  * @brief Generate CRC from "Jones" coefficients in normal format, runs baseline version
0290  * @returns 64 bit CRC
0291  */
0292 uint64_t
0293 crc64_jones_norm_base(uint64_t init_crc,        //!< initial CRC value, 64 bits
0294                       const unsigned char *buf, //!< buffer to calculate CRC on
0295                       uint64_t len              //!< buffer length in bytes (64-bit data)
0296 );
0297 
0298 /**
0299  * @brief Generate CRC from "Rocksoft" coefficients in reflected format.
0300  * @requires SSE3, CLMUL
0301  *
0302  * @returns 64 bit CRC
0303  */
0304 
0305 uint64_t
0306 crc64_rocksoft_refl_by8(uint64_t init_crc,        //!< initial CRC value, 64 bits
0307                         const unsigned char *buf, //!< buffer to calculate CRC on
0308                         uint64_t len              //!< buffer length in bytes (64-bit data)
0309 );
0310 
0311 /**
0312  * @brief Generate CRC from "Rocksoft" coefficients in reflected format, runs baseline version
0313  * @returns 64 bit CRC
0314  */
0315 uint64_t
0316 crc64_rocksoft_refl_base(uint64_t init_crc,        //!< initial CRC value, 64 bits
0317                          const unsigned char *buf, //!< buffer to calculate CRC on
0318                          uint64_t len              //!< buffer length in bytes (64-bit data)
0319 );
0320 
0321 /**
0322  * @brief Generate CRC from "Rocksoft" coefficients in normal format.
0323  * @requires SSE3, CLMUL
0324  *
0325  * @returns 64 bit CRC
0326  */
0327 
0328 uint64_t
0329 crc64_rocksoft_norm_by8(uint64_t init_crc,        //!< initial CRC value, 64 bits
0330                         const unsigned char *buf, //!< buffer to calculate CRC on
0331                         uint64_t len              //!< buffer length in bytes (64-bit data)
0332 );
0333 
0334 /**
0335  * @brief Generate CRC from "Rocksoft" coefficients in normal format, runs baseline version
0336  * @returns 64 bit CRC
0337  */
0338 uint64_t
0339 crc64_rocksoft_norm_base(uint64_t init_crc,        //!< initial CRC value, 64 bits
0340                          const unsigned char *buf, //!< buffer to calculate CRC on
0341                          uint64_t len              //!< buffer length in bytes (64-bit data)
0342 );
0343 
0344 #ifdef __cplusplus
0345 }
0346 #endif
0347 
0348 #endif // _CRC64_H_