]> icculus.org git repositories - icculus/xz.git/blob - src/liblzma/check/crc_macros.h
Put the interesting parts of XZ Utils into the public domain.
[icculus/xz.git] / src / liblzma / check / crc_macros.h
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 /// \file       crc_macros.h
4 /// \brief      Some endian-dependent macros for CRC32 and CRC64
5 //
6 //  Author:     Lasse Collin
7 //
8 //  This file has been put into the public domain.
9 //  You can do whatever you want with this file.
10 //
11 ///////////////////////////////////////////////////////////////////////////////
12
13 #ifdef WORDS_BIGENDIAN
14 #       include "../../common/bswap.h"
15
16 #       define A(x) ((x) >> 24)
17 #       define B(x) (((x) >> 16) & 0xFF)
18 #       define C(x) (((x) >> 8) & 0xFF)
19 #       define D(x) ((x) & 0xFF)
20
21 #       define S8(x) ((x) << 8)
22 #       define S32(x) ((x) << 32)
23
24 #else
25 #       define A(x) ((x) & 0xFF)
26 #       define B(x) (((x) >> 8) & 0xFF)
27 #       define C(x) (((x) >> 16) & 0xFF)
28 #       define D(x) ((x) >> 24)
29
30 #       define S8(x) ((x) >> 8)
31 #       define S32(x) ((x) >> 32)
32 #endif