proxygen
ChecksumDetail.h
Go to the documentation of this file.
1 /*
2  * Copyright 2013-present Facebook, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #include <folly/Portability.h>
20 
21 #if FOLLY_SSE_PREREQ(4, 2)
22 #include <immintrin.h>
23 #endif
24 
25 #include <stdint.h>
26 #include <cstddef>
27 
28 namespace folly {
29 namespace detail {
30 
42 crc32c_hw(const uint8_t* data, size_t nbytes, uint32_t startingChecksum = ~0U);
43 
48 bool crc32c_hw_supported();
49 
62 crc32c_sw(const uint8_t* data, size_t nbytes, uint32_t startingChecksum = ~0U);
63 
75 crc32_hw(const uint8_t* data, size_t nbytes, uint32_t startingChecksum = ~0U);
76 
77 #if FOLLY_SSE_PREREQ(4, 2)
79 crc32_hw_aligned(uint32_t remainder, const __m128i* p, size_t vec_count);
80 #endif
81 
86 bool crc32_hw_supported();
87 
100 crc32_sw(const uint8_t* data, size_t nbytes, uint32_t startingChecksum = ~0U);
101 
102 /* See Checksum.h for details.
103  *
104  * crc2len *must* be a power of two >= 4.
105  */
106 uint32_t crc32_combine_sw(uint32_t crc1, uint32_t crc2, size_t crc2len);
107 uint32_t crc32_combine_hw(uint32_t crc1, uint32_t crc2, size_t crc2len);
108 uint32_t crc32c_combine_sw(uint32_t crc1, uint32_t crc2, size_t crc2len);
109 uint32_t crc32c_combine_hw(uint32_t crc1, uint32_t crc2, size_t crc2len);
110 
111 } // namespace detail
112 } // namespace folly
uint32_t crc32_combine_hw(uint32_t crc1, uint32_t crc2, size_t crc2len)
uint32_t crc32_sw(const uint8_t *data, size_t nbytes, uint32_t startingChecksum)
Definition: Checksum.cpp:121
—— Concurrent Priority Queue Implementation ——
Definition: AtomicBitSet.h:29
uint32_t crc32c_combine_hw(uint32_t crc1, uint32_t crc2, size_t crc2len)
uint32_t crc32_combine_sw(uint32_t crc1, uint32_t crc2, size_t crc2len)
uint32_t crc32c_combine_sw(uint32_t crc1, uint32_t crc2, size_t crc2len)
uint32_t crc32c_hw(const uint8_t *data, size_t nbytes, uint32_t startingChecksum=~0U)
constexpr auto data(C &c) -> decltype(c.data())
Definition: Access.h:71
bool crc32_hw_supported()
Definition: Checksum.cpp:87
uint32_t crc32c_sw(const uint8_t *data, size_t nbytes, uint32_t startingChecksum)
Definition: Checksum.cpp:115
uint32_t crc32_hw(const uint8_t *, size_t, uint32_t)
Definition: Checksum.cpp:76
bool crc32c_hw_supported()
Definition: Checksum.cpp:83