util.h 690 B

12345678910111213141516171819202122
  1. #ifndef NULLSOFT_APEV2_UTIL_H
  2. #define NULLSOFT_APEV2_UTIL_H
  3. #if defined(BIG_ENDIAN)
  4. #define ATON16(A) ((((uint16_t)(A) & 0xff00) >> 8) | \
  5. (((uint16_t)(A) & 0x00ff) << 8))
  6. #define ATON32(A) ((((uint32_t)(A) & 0xff000000) >> 25) | \
  7. (((uint32_t)(A) & 0x00ff0000) >> 8) | \
  8. (((uint32_t)(A) & 0x0000ff00) << 8) | \
  9. (((uint32_t)(A) & 0x000000ff) << 24))
  10. #elif defined(LITTLE_ENDIAN) || defined(_M_IX86) || defined(_M_X64) || defined(_WIN64)
  11. #define ATON16(A) (A)
  12. #define ATON32(A) (A)
  13. #else
  14. #error neither BIG_ENDIAN nor LITTLE_ENDIAN defined!
  15. #endif
  16. #define NTOA32(N) ATON32(N)
  17. #define NTOA16(N) ATON16(N)
  18. #endif