source: include/CRC64.h @ b8df02e

Revision b8df02e, 3.5 KB checked in by Hal Finkel <hfinkel@…>, 9 years ago (diff)

Update to new open-source license

  • Property mode set to 100644
Line 
1/*
2 * *****************************************************************************
3 *                   Copyright (C) 2014, UChicago Argonne, LLC
4 *                              All Rights Reserved
5 *             High-Performance CRC64 Library (ANL-SF-14-095)
6 *                    Hal Finkel, Argonne National Laboratory
7 *
8 *                              OPEN SOURCE LICENSE
9 *
10 * Under the terms of Contract No. DE-AC02-06CH11357 with UChicago Argonne, LLC,
11 * the U.S. Government retains certain rights in this software.
12 *
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions are met:
15 *
16 * 1. Redistributions of source code must retain the above copyright notice, this
17 *    list of conditions and the following disclaimer.
18 *
19 * 2. Redistributions in binary form must reproduce the above copyright notice,
20 *    this list of conditions and the following disclaimer in the documentation
21 *    and/or other materials provided with the distribution.
22 *
23 * 3. Neither the names of UChicago Argonne, LLC or the Department of Energy nor
24 *    the names of its contributors may be used to endorse or promote products
25 *    derived from this software without specific prior written permission.
26 * 
27 * *****************************************************************************
28 *                                  DISCLAIMER
29 *
30 * THE SOFTWARE IS SUPPLIED "AS IS" WITHOUT WARRANTY OF ANY KIND.
31 *
32 * NEITHER THE UNTED STATES GOVERNMENT, NOR THE UNITED STATES DEPARTMENT OF
33 * ENERGY, NOR UCHICAGO ARGONNE, LLC, NOR ANY OF THEIR EMPLOYEES, MAKES ANY
34 * WARRANTY, EXPRESS OR IMPLIED, OR ASSUMES ANY LEGAL LIABILITY OR RESPONSIBILITY
35 * FOR THE ACCURACY, COMPLETENESS, OR USEFULNESS OF ANY INFORMATION, DATA,
36 * APPARATUS, PRODUCT, OR PROCESS DISCLOSED, OR REPRESENTS THAT ITS USE WOULD NOT
37 * INFRINGE PRIVATELY OWNED RIGHTS.
38 *
39 * *****************************************************************************
40 */
41
42#ifndef CRC64_H
43#define CRC64_H
44
45#include <stdlib.h>
46#include <stdint.h>
47
48/*
49 * These functions compute the CRC-64 checksum on a block of data
50 * and provide a way to combine the checksums on two blocks of data.
51 * For more information, see:
52 * http://en.wikipedia.org/wiki/Computation_of_CRC
53 * http://checksumcrc.blogspot.com/2011/12/should-you-use-crc-or-checksum.html
54 * http://crcutil.googlecode.com/files/crc-doc.1.0.pdf
55 * http://www.ross.net/crc/download/crc_v3.txt
56 * This implementation uses the ECMA-182 polynomial with -1 initialization, and
57 * computes the bit-reversed CRC.
58 */
59
60#ifdef __cplusplus
61extern "C" {
62#endif
63
64/*
65 * Calculate the CRC64 of the provided buffer using the slow reference
66 * implementation (in serial).
67 */
68uint64_t crc64_slow(const void *input, size_t nbytes);
69
70/*
71 * Calculate the CRC64 of the provided buffer (in serial).
72 */
73uint64_t crc64(const void *input, size_t nbytes);
74
75/*
76 * Calculate the CRC64 of the provided buffer, in parallel if possible.
77 */
78uint64_t crc64_omp(const void *input, size_t nbytes);
79
80/*
81 * Calculate the 'check bytes' for the provided CRC64. If these bytes are
82 * appended to the original buffer, then the new total CRC64 should be -1.
83 */
84void crc64_invert(uint64_t cs, void *check_bytes);
85
86/*
87 * Given the CRC64 of the first part of a buffer, and the CRC64 and length of
88 * the second part of a buffer, calculate the CRC64 of the complete buffer.
89 */
90uint64_t crc64_combine(uint64_t cs1, uint64_t cs2, size_t nbytes2);
91
92#ifdef __cplusplus
93}
94#endif
95
96#endif // CRC64_H
97
Note: See TracBrowser for help on using the repository browser.