xref: /aosp_15_r20/external/e2fsprogs/lib/ext2fs/crc16.h (revision 6a54128f25917bfc36a8a6e9d722c04a0b4641b6)
1*6a54128fSAndroid Build Coastguard Worker /*
2*6a54128fSAndroid Build Coastguard Worker  *	crc16.h - CRC-16 routine
3*6a54128fSAndroid Build Coastguard Worker  *
4*6a54128fSAndroid Build Coastguard Worker  * Implements the standard CRC-16:
5*6a54128fSAndroid Build Coastguard Worker  *   Width 16
6*6a54128fSAndroid Build Coastguard Worker  *   Poly  0x8005 (x16 + x15 + x2 + 1)
7*6a54128fSAndroid Build Coastguard Worker  *   Init  0
8*6a54128fSAndroid Build Coastguard Worker  *
9*6a54128fSAndroid Build Coastguard Worker  * Copyright (c) 2005 Ben Gardner <[email protected]>
10*6a54128fSAndroid Build Coastguard Worker  *
11*6a54128fSAndroid Build Coastguard Worker  * This source code is licensed under the GNU General Public License,
12*6a54128fSAndroid Build Coastguard Worker  * Version 2. See the file COPYING for more details.
13*6a54128fSAndroid Build Coastguard Worker  */
14*6a54128fSAndroid Build Coastguard Worker 
15*6a54128fSAndroid Build Coastguard Worker #ifndef __CRC16_H
16*6a54128fSAndroid Build Coastguard Worker #define __CRC16_H
17*6a54128fSAndroid Build Coastguard Worker 
18*6a54128fSAndroid Build Coastguard Worker /* for an unknown reason, PPC treats __u16 as signed and keeps doing sign
19*6a54128fSAndroid Build Coastguard Worker  * extension on the value.  Instead, use only the low 16 bits of an
20*6a54128fSAndroid Build Coastguard Worker  * unsigned int for holding the CRC value to avoid this.
21*6a54128fSAndroid Build Coastguard Worker  */
22*6a54128fSAndroid Build Coastguard Worker typedef unsigned int crc16_t;
23*6a54128fSAndroid Build Coastguard Worker 
24*6a54128fSAndroid Build Coastguard Worker extern crc16_t ext2fs_crc16(crc16_t crc, const void *buffer, unsigned int len);
25*6a54128fSAndroid Build Coastguard Worker 
26*6a54128fSAndroid Build Coastguard Worker #endif /* __CRC16_H */
27