]>
Commit | Line | Data |
---|---|---|
9f95a23c TL |
1 | /********************************************************************** |
2 | Copyright(c) 2011-2016 Intel Corporation All rights reserved. | |
3 | ||
4 | Redistribution and use in source and binary forms, with or without | |
5 | modification, are permitted provided that the following conditions | |
6 | are met: | |
7 | * Redistributions of source code must retain the above copyright | |
8 | notice, this list of conditions and the following disclaimer. | |
9 | * Redistributions in binary form must reproduce the above copyright | |
10 | notice, this list of conditions and the following disclaimer in | |
11 | the documentation and/or other materials provided with the | |
12 | distribution. | |
13 | * Neither the name of Intel Corporation nor the names of its | |
14 | contributors may be used to endorse or promote products derived | |
15 | from this software without specific prior written permission. | |
16 | ||
17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
28 | **********************************************************************/ | |
29 | ||
30 | ||
31 | /** | |
32 | * @file crc64.h | |
33 | * @brief CRC64 functions. | |
34 | */ | |
35 | ||
36 | ||
37 | #ifndef _CRC64_H_ | |
38 | #define _CRC64_H_ | |
39 | ||
40 | #include <stdint.h> | |
41 | ||
42 | #ifdef __cplusplus | |
43 | extern "C" { | |
44 | #endif | |
45 | ||
46 | ||
47 | /* Multi-binary functions */ | |
48 | ||
49 | /** | |
50 | * @brief Generate CRC from ECMA-182 standard in reflected format, runs | |
51 | * appropriate version. | |
52 | * | |
53 | * This function determines what instruction sets are enabled and | |
54 | * selects the appropriate version at runtime. | |
55 | * @returns 64 bit CRC | |
56 | */ | |
57 | uint64_t crc64_ecma_refl( | |
58 | uint64_t init_crc, //!< initial CRC value, 64 bits | |
59 | const unsigned char *buf, //!< buffer to calculate CRC on | |
60 | uint64_t len //!< buffer length in bytes (64-bit data) | |
61 | ); | |
62 | ||
63 | /** | |
64 | * @brief Generate CRC from ECMA-182 standard in normal format, runs | |
65 | * appropriate version. | |
66 | * | |
67 | * This function determines what instruction sets are enabled and | |
68 | * selects the appropriate version at runtime. | |
69 | * @returns 64 bit CRC | |
70 | */ | |
71 | uint64_t crc64_ecma_norm( | |
72 | uint64_t init_crc, //!< initial CRC value, 64 bits | |
73 | const unsigned char *buf, //!< buffer to calculate CRC on | |
74 | uint64_t len //!< buffer length in bytes (64-bit data) | |
75 | ); | |
76 | ||
77 | /** | |
78 | * @brief Generate CRC from ISO standard in reflected format, runs | |
79 | * appropriate version. | |
80 | * | |
81 | * This function determines what instruction sets are enabled and | |
82 | * selects the appropriate version at runtime. | |
83 | * @returns 64 bit CRC | |
84 | */ | |
85 | uint64_t crc64_iso_refl( | |
86 | uint64_t init_crc, //!< initial CRC value, 64 bits | |
87 | const unsigned char *buf, //!< buffer to calculate CRC on | |
88 | uint64_t len //!< buffer length in bytes (64-bit data) | |
89 | ); | |
90 | ||
91 | /** | |
92 | * @brief Generate CRC from ISO standard in normal format, runs | |
93 | * appropriate version. | |
94 | * | |
95 | * This function determines what instruction sets are enabled and | |
96 | * selects the appropriate version at runtime. | |
97 | * @returns 64 bit CRC | |
98 | */ | |
99 | uint64_t crc64_iso_norm( | |
100 | uint64_t init_crc, //!< initial CRC value, 64 bits | |
101 | const unsigned char *buf, //!< buffer to calculate CRC on | |
102 | uint64_t len //!< buffer length in bytes (64-bit data) | |
103 | ); | |
104 | ||
105 | /** | |
106 | * @brief Generate CRC from "Jones" coefficients in reflected format, runs | |
107 | * appropriate version. | |
108 | * | |
109 | * This function determines what instruction sets are enabled and | |
110 | * selects the appropriate version at runtime. | |
111 | * @returns 64 bit CRC | |
112 | */ | |
113 | uint64_t crc64_jones_refl( | |
114 | uint64_t init_crc, //!< initial CRC value, 64 bits | |
115 | const unsigned char *buf, //!< buffer to calculate CRC on | |
116 | uint64_t len //!< buffer length in bytes (64-bit data) | |
117 | ); | |
118 | ||
119 | /** | |
120 | * @brief Generate CRC from "Jones" coefficients in normal format, runs | |
121 | * appropriate version. | |
122 | * | |
123 | * This function determines what instruction sets are enabled and | |
124 | * selects the appropriate version at runtime. | |
125 | * @returns 64 bit CRC | |
126 | */ | |
127 | uint64_t crc64_jones_norm( | |
128 | uint64_t init_crc, //!< initial CRC value, 64 bits | |
129 | const unsigned char *buf, //!< buffer to calculate CRC on | |
130 | uint64_t len //!< buffer length in bytes (64-bit data) | |
131 | ); | |
132 | ||
133 | /* Arch specific versions */ | |
134 | ||
135 | /** | |
136 | * @brief Generate CRC from ECMA-182 standard in reflected format. | |
137 | * @requires SSE3, CLMUL | |
138 | * | |
139 | * @returns 64 bit CRC | |
140 | */ | |
141 | ||
142 | uint64_t crc64_ecma_refl_by8( | |
143 | uint64_t init_crc, //!< initial CRC value, 64 bits | |
144 | const unsigned char *buf, //!< buffer to calculate CRC on | |
145 | uint64_t len //!< buffer length in bytes (64-bit data) | |
146 | ); | |
147 | ||
148 | /** | |
149 | * @brief Generate CRC from ECMA-182 standard in normal format. | |
150 | * @requires SSE3, CLMUL | |
151 | * | |
152 | * @returns 64 bit CRC | |
153 | */ | |
154 | ||
155 | uint64_t crc64_ecma_norm_by8( | |
156 | uint64_t init_crc, //!< initial CRC value, 64 bits | |
157 | const unsigned char *buf, //!< buffer to calculate CRC on | |
158 | uint64_t len //!< buffer length in bytes (64-bit data) | |
159 | ); | |
160 | ||
161 | /** | |
162 | * @brief Generate CRC from ECMA-182 standard in reflected format, runs baseline version | |
163 | * @returns 64 bit CRC | |
164 | */ | |
165 | uint64_t crc64_ecma_refl_base( | |
166 | uint64_t init_crc, //!< initial CRC value, 64 bits | |
167 | const unsigned char *buf, //!< buffer to calculate CRC on | |
168 | uint64_t len //!< buffer length in bytes (64-bit data) | |
169 | ); | |
170 | ||
171 | /** | |
172 | * @brief Generate CRC from ECMA-182 standard in normal format, runs baseline version | |
173 | * @returns 64 bit CRC | |
174 | */ | |
175 | uint64_t crc64_ecma_norm_base( | |
176 | uint64_t init_crc, //!< initial CRC value, 64 bits | |
177 | const unsigned char *buf, //!< buffer to calculate CRC on | |
178 | uint64_t len //!< buffer length in bytes (64-bit data) | |
179 | ); | |
180 | ||
181 | /** | |
182 | * @brief Generate CRC from ISO standard in reflected format. | |
183 | * @requires SSE3, CLMUL | |
184 | * | |
185 | * @returns 64 bit CRC | |
186 | */ | |
187 | ||
188 | uint64_t crc64_iso_refl_by8( | |
189 | uint64_t init_crc, //!< initial CRC value, 64 bits | |
190 | const unsigned char *buf, //!< buffer to calculate CRC on | |
191 | uint64_t len //!< buffer length in bytes (64-bit data) | |
192 | ); | |
193 | ||
194 | /** | |
195 | * @brief Generate CRC from ISO standard in normal format. | |
196 | * @requires SSE3, CLMUL | |
197 | * | |
198 | * @returns 64 bit CRC | |
199 | */ | |
200 | ||
201 | uint64_t crc64_iso_norm_by8( | |
202 | uint64_t init_crc, //!< initial CRC value, 64 bits | |
203 | const unsigned char *buf, //!< buffer to calculate CRC on | |
204 | uint64_t len //!< buffer length in bytes (64-bit data) | |
205 | ); | |
206 | ||
207 | /** | |
208 | * @brief Generate CRC from ISO standard in reflected format, runs baseline version | |
209 | * @returns 64 bit CRC | |
210 | */ | |
211 | uint64_t crc64_iso_refl_base( | |
212 | uint64_t init_crc, //!< initial CRC value, 64 bits | |
213 | const unsigned char *buf, //!< buffer to calculate CRC on | |
214 | uint64_t len //!< buffer length in bytes (64-bit data) | |
215 | ); | |
216 | ||
217 | /** | |
218 | * @brief Generate CRC from ISO standard in normal format, runs baseline version | |
219 | * @returns 64 bit CRC | |
220 | */ | |
221 | uint64_t crc64_iso_norm_base( | |
222 | uint64_t init_crc, //!< initial CRC value, 64 bits | |
223 | const unsigned char *buf, //!< buffer to calculate CRC on | |
224 | uint64_t len //!< buffer length in bytes (64-bit data) | |
225 | ); | |
226 | ||
227 | /** | |
228 | * @brief Generate CRC from "Jones" coefficients in reflected format. | |
229 | * @requires SSE3, CLMUL | |
230 | * | |
231 | * @returns 64 bit CRC | |
232 | */ | |
233 | ||
234 | uint64_t crc64_jones_refl_by8( | |
235 | uint64_t init_crc, //!< initial CRC value, 64 bits | |
236 | const unsigned char *buf, //!< buffer to calculate CRC on | |
237 | uint64_t len //!< buffer length in bytes (64-bit data) | |
238 | ); | |
239 | ||
240 | /** | |
241 | * @brief Generate CRC from "Jones" coefficients in normal format. | |
242 | * @requires SSE3, CLMUL | |
243 | * | |
244 | * @returns 64 bit CRC | |
245 | */ | |
246 | ||
247 | uint64_t crc64_jones_norm_by8( | |
248 | uint64_t init_crc, //!< initial CRC value, 64 bits | |
249 | const unsigned char *buf, //!< buffer to calculate CRC on | |
250 | uint64_t len //!< buffer length in bytes (64-bit data) | |
251 | ); | |
252 | ||
253 | /** | |
254 | * @brief Generate CRC from "Jones" coefficients in reflected format, runs baseline version | |
255 | * @returns 64 bit CRC | |
256 | */ | |
257 | uint64_t crc64_jones_refl_base( | |
258 | uint64_t init_crc, //!< initial CRC value, 64 bits | |
259 | const unsigned char *buf, //!< buffer to calculate CRC on | |
260 | uint64_t len //!< buffer length in bytes (64-bit data) | |
261 | ); | |
262 | ||
263 | /** | |
264 | * @brief Generate CRC from "Jones" coefficients in normal format, runs baseline version | |
265 | * @returns 64 bit CRC | |
266 | */ | |
267 | uint64_t crc64_jones_norm_base( | |
268 | uint64_t init_crc, //!< initial CRC value, 64 bits | |
269 | const unsigned char *buf, //!< buffer to calculate CRC on | |
270 | uint64_t len //!< buffer length in bytes (64-bit data) | |
271 | ); | |
272 | ||
273 | #ifdef __cplusplus | |
274 | } | |
275 | #endif | |
276 | ||
277 | #endif // _CRC64_H_ |