1 ///////////////////////////////////////////////////////////////////////////////
3 /// \file check_byteswap.h
4 /// \brief Byteswapping needed by the checks
6 // This code has been put into the public domain.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 ///////////////////////////////////////////////////////////////////////////////
14 #ifndef LZMA_CHECK_BYTESWAP_H
15 #define LZMA_CHECK_BYTESWAP_H
21 // byteswap.h is a GNU extension. It contains inline assembly versions
22 // for byteswapping. When byteswap.h is not available, we use generic code.
23 #ifdef HAVE_BYTESWAP_H
24 # include <byteswap.h>
26 # define bswap_32(num) \
28 | (((num) << 8) & UINT32_C(0x00FF0000)) \
29 | (((num) >> 8) & UINT32_C(0x0000FF00)) \
32 # define bswap_64(num) \
34 | (((num) << 40) & UINT64_C(0x00FF000000000000)) \
35 | (((num) << 24) & UINT64_C(0x0000FF0000000000)) \
36 | (((num) << 8) & UINT64_C(0x000000FF00000000)) \
37 | (((num) >> 8) & UINT64_C(0x00000000FF000000)) \
38 | (((num) >> 24) & UINT64_C(0x0000000000FF0000)) \
39 | (((num) >> 40) & UINT64_C(0x000000000000FF00)) \