2 * Copyright 2013 Facebook, Inc.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef FOLLY_DETAIL_CHECKSUMDETAIL_H_
18 #define FOLLY_DETAIL_CHECKSUMDETAIL_H_
20 namespace folly { namespace detail {
23 * Compute a CRC-32C checksum of a buffer using a hardware-accelerated
26 * @note This function is exposed to support special cases where the
27 * calling code is absolutely certain it ought to invoke a hardware-
28 * accelerated CRC-32C implementation - unit tests, for example. For
29 * all other scenarios, please call crc32c() and let it pick an
30 * implementation based on the capabilities of the underlying CPU.
32 uint32_t crc32c_hw(const uint8_t* data, size_t nbytes,
33 uint32_t startingChecksum = ~0U);
36 * Check whether a hardware-accelerated CRC-32C implementation is
37 * supported on the current CPU.
39 bool crc32c_hw_supported();
42 * Compute a CRC-32C checksum of a buffer using a portable,
43 * software-only implementation.
45 * @note This function is exposed to support special cases where the
46 * calling code is absolutely certain it wants to use the software
47 * implementation instead of the hardware-accelerated code - unit
48 * tests, for example. For all other scenarios, please call crc32c()
49 * and let it pick an implementation based on the capabilities of
52 uint32_t crc32c_sw(const uint8_t* data, size_t nbytes,
53 uint32_t startingChecksum = ~0U);
58 #endif /* FOLLY_DETAIL_CHECKSUMDETAIL_H_ */