Debian Codegraph @

crt/aws-checksums/include/aws/checksums/private/crc32_priv.h

raw symbols SCIP
1 #ifndef AWS_CHECKSUMS_PRIVATE_CRC_PRIV_H
2 #define AWS_CHECKSUMS_PRIVATE_CRC_PRIV_H
3 /**
4 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
5 * SPDX-License-Identifier: Apache-2.0.
6 */
7
8 #define AWS_CRC32_SIZE_BYTES 4
9 #include <aws/checksums/exports.h>
10 #include <aws/common/common.h>
11
12 #include <aws/common/config.h>
13 #include <stdint.h>
14
15 AWS_EXTERN_C_BEGIN
16
17 /* Computes CRC32 (Ethernet, gzip, et. al.) using a (slow) reference implementation. */
18 AWS_CHECKSUMS_API uint32_t aws_checksums_crc32_sw(const uint8_t *input, int length, uint32_t previousCrc32);
19
20 /* Computes the Castagnoli CRC32c (iSCSI) using a (slow) reference implementation. */
21 AWS_CHECKSUMS_API uint32_t aws_checksums_crc32c_sw(const uint8_t *input, int length, uint32_t previousCrc32c);
22
23 AWS_CHECKSUMS_API uint32_t aws_checksums_crc32_combine_sw(uint32_t crc1, uint32_t crc2, uint64_t len);
24
25 AWS_CHECKSUMS_API uint32_t aws_checksums_crc32c_combine_sw(uint32_t crc1, uint32_t crc2, uint64_t len);
26
27 #if defined(AWS_USE_CPU_EXTENSIONS) && defined(AWS_ARCH_ARM64)
28 uint32_t aws_checksums_crc32_armv8(const uint8_t *input, int length, uint32_t previous_crc32);
29 uint32_t aws_checksums_crc32c_armv8(const uint8_t *input, int length, uint32_t previous_crc32c);
30 #elif defined(AWS_USE_CPU_EXTENSIONS) && defined(AWS_ARCH_INTEL)
31 # if defined(AWS_ARCH_INTEL_X64)
32 typedef uint64_t *slice_ptr_type;
33 typedef uint64_t slice_ptr_int_type;
34 # define crc_intrin_fn _mm_crc32_u64
35
36 # if !defined(_MSC_VER)
37 uint32_t aws_checksums_crc32c_clmul_sse42(const uint8_t *data, int length, uint32_t previous_crc32c);
38 # endif
39
40 # else
41 typedef uint32_t *slice_ptr_type;
42 typedef uint32_t slice_ptr_int_type;
43 # define crc_intrin_fn _mm_crc32_u32
44 # endif
45 uint32_t aws_checksums_crc32c_intel_avx512_with_sse_fallback(
46 const uint8_t *input,
47 int length,
48 uint32_t previous_crc32c);
49
50 #endif
51
52 typedef struct {
53 uint64_t mu_poly[2]; /* Barrett mu / polynomial P(x) */
54 uint64_t shift_factors[16][16][2];
55 } aws_checksums_crc32_constants_t;
56
57 extern aws_checksums_crc32_constants_t aws_checksums_crc32_constants;
58 extern aws_checksums_crc32_constants_t aws_checksums_crc32c_constants;
59
60 AWS_EXTERN_C_END
61
62 #endif /* AWS_CHECKSUMS_PRIVATE_CRC_PRIV_H */