• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2016 The Android Open Source Project
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 #ifndef _NANOHUB_CRC_H_
18 #define _NANOHUB_CRC_H_
19 
20 #include <stddef.h>
21 #include <stdint.h>
22 
23 #define CRC_RESIDUE 0xC704DD7BUL
24 #define CRC_INIT    0xFFFFFFFFUL
25 
26 /**
27  * Implements CRC with the following parameters:
28  *
29  * Width:   32
30  * Poly:    04C11DB7
31  * Init:    FFFFFFFF
32  * RefIn:   False
33  * RefOut:  False
34  * XorOut:  00000000
35  *
36  * The CRC implementation will pad the buffer with zeroes to the nearest
37  * multiple of 4 bytes (if necessary).
38  */
39 uint32_t crc32(const void *buf, size_t size, uint32_t crc);
40 
41 /* concrete public implementation of crc32() w/o HW acceleration */
42 uint32_t soft_crc32(const void *buf, size_t size, uint32_t crc);
43 
44 
45 #endif /* _NANOHUB_CRC_H_ */
46