~ubuntu-branches/ubuntu/vivid/python-snappy/vivid

« back to all changes in this revision

Viewing changes to crc32c.h

  • Committer: Package Import Robot
  • Author(s): Shell Xu
  • Date: 2013-06-02 18:59:04 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20130602185904-d91mdohuzqm461c8
Tags: 0.5-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * \file crc32c.h
 
3
 * Functions and types for CRC checks.
 
4
 *
 
5
 * Generated on Wed Nov  7 16:14:52 2012,
 
6
 * by pycrc v0.7.11, http://www.tty1.net/pycrc/
 
7
 * using the configuration:
 
8
 *    Width        = 32
 
9
 *    Poly         = 0x1edc6f41
 
10
 *    XorIn        = 0xffffffff
 
11
 *    ReflectIn    = True
 
12
 *    XorOut       = 0xffffffff
 
13
 *    ReflectOut   = True
 
14
 *    Algorithm    = table-driven
 
15
 *****************************************************************************/
 
16
#ifndef __CRC32C_H__
 
17
#define __CRC32C_H__
 
18
 
 
19
#include <stdlib.h>
 
20
#include <stdint.h>
 
21
 
 
22
#ifdef __cplusplus
 
23
extern "C" {
 
24
#endif
 
25
 
 
26
 
 
27
/**
 
28
 * The definition of the used algorithm.
 
29
 *****************************************************************************/
 
30
#define CRC_ALGO_TABLE_DRIVEN 1
 
31
 
 
32
 
 
33
/**
 
34
 * The type of the CRC values.
 
35
 *
 
36
 * This type must be big enough to contain at least 32 bits.
 
37
 *****************************************************************************/
 
38
typedef uint32_t crc_t;
 
39
 
 
40
 
 
41
/**
 
42
 * Reflect all bits of a \a data word of \a data_len bytes.
 
43
 *
 
44
 * \param data         The data word to be reflected.
 
45
 * \param data_len     The width of \a data expressed in number of bits.
 
46
 * \return             The reflected data.
 
47
 *****************************************************************************/
 
48
crc_t crc_reflect(crc_t data, size_t data_len);
 
49
 
 
50
 
 
51
/**
 
52
 * Calculate the initial crc value.
 
53
 *
 
54
 * \return     The initial crc value.
 
55
 *****************************************************************************/
 
56
static inline crc_t crc_init(void)
 
57
{
 
58
    return 0xffffffff;
 
59
}
 
60
 
 
61
 
 
62
/**
 
63
 * Update the crc value with new data.
 
64
 *
 
65
 * \param crc      The current crc value.
 
66
 * \param data     Pointer to a buffer of \a data_len bytes.
 
67
 * \param data_len Number of bytes in the \a data buffer.
 
68
 * \return         The updated crc value.
 
69
 *****************************************************************************/
 
70
crc_t crc_update(crc_t crc, const unsigned char *data, size_t data_len);
 
71
 
 
72
 
 
73
/**
 
74
 * Calculate the final crc value.
 
75
 *
 
76
 * \param crc  The current crc value.
 
77
 * \return     The final crc value.
 
78
 *****************************************************************************/
 
79
static inline crc_t crc_finalize(crc_t crc)
 
80
{
 
81
    return crc ^ 0xffffffff;
 
82
}
 
83
 
 
84
 
 
85
#ifdef __cplusplus
 
86
}           /* closing brace for extern "C" */
 
87
#endif
 
88
 
 
89
#endif      /* __CRC32C_H__ */