folly: replace old-style header guards with "pragma once"
[folly.git] / folly / detail / ChecksumDetail.h
1 /*
2  * Copyright 2016 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 namespace folly { namespace detail {
20
21 /**
22  * Compute a CRC-32C checksum of a buffer using a hardware-accelerated
23  * implementation.
24  *
25  * @note This function is exposed to support special cases where the
26  *       calling code is absolutely certain it ought to invoke a hardware-
27  *       accelerated CRC-32C implementation - unit tests, for example.  For
28  *       all other scenarios, please call crc32c() and let it pick an
29  *       implementation based on the capabilities of the underlying CPU.
30  */
31 uint32_t crc32c_hw(const uint8_t* data, size_t nbytes,
32     uint32_t startingChecksum = ~0U);
33
34 /**
35  * Check whether a hardware-accelerated CRC-32C implementation is
36  * supported on the current CPU.
37  */
38 bool crc32c_hw_supported();
39
40 /**
41  * Compute a CRC-32C checksum of a buffer using a portable,
42  * software-only implementation.
43  *
44  * @note This function is exposed to support special cases where the
45  *       calling code is absolutely certain it wants to use the software
46  *       implementation instead of the hardware-accelerated code - unit
47  *       tests, for example.  For all other scenarios, please call crc32c()
48  *       and let it pick an implementation based on the capabilities of
49  *       the underlying CPU.
50  */
51 uint32_t crc32c_sw(const uint8_t* data, size_t nbytes,
52     uint32_t startingChecksum = ~0U);
53
54
55 }} // folly::detail