codecs.h 902 B

1234567891011121314151617181920212223242526272829303132333435
  1. #pragma once
  2. // Define machine endianness. This is for GCC:
  3. #if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
  4. #define BASE64_SSSE3_LITTLE_ENDIAN 1
  5. #else
  6. #define BASE64_SSSE3_LITTLE_ENDIAN 0
  7. #endif
  8. // This is for Clang:
  9. #ifdef __LITTLE_ENDIAN__
  10. #define BASE64_SSSE3_LITTLE_ENDIAN 1
  11. #endif
  12. #ifdef __BIG_ENDIAN__
  13. #define BASE64_SSSE3_LITTLE_ENDIAN 0
  14. #endif
  15. // Endian conversion functions
  16. #if BASE64_SSSE3_LITTLE_ENDIAN
  17. #define cpu_to_be32(x) __builtin_bswap32(x)
  18. #define cpu_to_be64(x) __builtin_bswap64(x)
  19. #define be32_to_cpu(x) __builtin_bswap32(x)
  20. #define be64_to_cpu(x) __builtin_bswap64(x)
  21. #else
  22. #define cpu_to_be32(x) (x)
  23. #define cpu_to_be64(x) (x)
  24. #define be32_to_cpu(x) (x)
  25. #define be64_to_cpu(x) (x)
  26. #endif
  27. // These tables are used by all codecs
  28. // for fallback plain encoding/decoding:
  29. extern const uint8_t ssse3_base64_table_enc[];
  30. extern const uint8_t ssse3_base64_table_dec[];