blob: e3d8b4a517da19156ac7f90d03a616797a23173e [file] [log] [blame]
Jose R. Santosca2634a2007-10-21 21:03:19 -05001/*
2 * crc16.h - CRC-16 routine
3 *
4 * Implements the standard CRC-16:
5 * Width 16
6 * Poly 0x8005 (x16 + x15 + x2 + 1)
7 * Init 0
8 *
9 * Copyright (c) 2005 Ben Gardner <bgardner@wabtec.com>
10 *
11 * This source code is licensed under the GNU General Public License,
12 * Version 2. See the file COPYING for more details.
13 */
14
15#ifndef __CRC16_H
16#define __CRC16_H
17
18#include <ext2fs/ext2_types.h>
19
Jose R. Santosca2634a2007-10-21 21:03:19 -050020/* for an unknown reason, PPC treats __u16 as signed and keeps doing sign
21 * extension on the value. Instead, use only the low 16 bits of an
22 * unsigned int for holding the CRC value to avoid this.
23 */
Theodore Ts'oc4dcb1c2008-08-24 22:44:33 -040024typedef unsigned int crc16_t;
Jose R. Santosca2634a2007-10-21 21:03:19 -050025
Theodore Ts'oc4dcb1c2008-08-24 22:44:33 -040026extern crc16_t ext2fs_crc16(crc16_t crc, const void *buffer, unsigned int len);
Jose R. Santosca2634a2007-10-21 21:03:19 -050027
28#endif /* __CRC16_H */