crc_macros.h 787 B

123456789101112131415161718192021222324252627282930
  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. #ifdef WORDS_BIGENDIAN
  13. # define A(x) ((x) >> 24)
  14. # define B(x) (((x) >> 16) & 0xFF)
  15. # define C(x) (((x) >> 8) & 0xFF)
  16. # define D(x) ((x) & 0xFF)
  17. # define S8(x) ((x) << 8)
  18. # define S32(x) ((x) << 32)
  19. #else
  20. # define A(x) ((x) & 0xFF)
  21. # define B(x) (((x) >> 8) & 0xFF)
  22. # define C(x) (((x) >> 16) & 0xFF)
  23. # define D(x) ((x) >> 24)
  24. # define S8(x) ((x) >> 8)
  25. # define S32(x) ((x) >> 32)
  26. #endif