codec.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #include <stdint.h>
  2. #include <stddef.h>
  3. #include <stdlib.h>
  4. #include "../../../include/libbase64.h"
  5. #include "../../tables/tables.h"
  6. #include "../../codecs.h"
  7. #include "config.h"
  8. #include "../../env.h"
  9. #if HAVE_SSE41
  10. #include <smmintrin.h>
  11. // Only enable inline assembly on supported compilers and on 64-bit CPUs.
  12. #ifndef BASE64_SSE41_USE_ASM
  13. # if (defined(__GNUC__) || defined(__clang__)) && BASE64_WORDSIZE == 64
  14. # define BASE64_SSE41_USE_ASM 1
  15. # else
  16. # define BASE64_SSE41_USE_ASM 0
  17. # endif
  18. #endif
  19. #include "../ssse3/dec_reshuffle.c"
  20. #include "../ssse3/dec_loop.c"
  21. #if BASE64_SSE41_USE_ASM
  22. # include "../ssse3/enc_loop_asm.c"
  23. #else
  24. # include "../ssse3/enc_translate.c"
  25. # include "../ssse3/enc_reshuffle.c"
  26. # include "../ssse3/enc_loop.c"
  27. #endif
  28. #endif // HAVE_SSE41
  29. BASE64_ENC_FUNCTION(sse41)
  30. {
  31. #if HAVE_SSE41
  32. #include "../generic/enc_head.c"
  33. enc_loop_ssse3(&s, &slen, &o, &olen);
  34. #include "../generic/enc_tail.c"
  35. #else
  36. BASE64_ENC_STUB
  37. #endif
  38. }
  39. BASE64_DEC_FUNCTION(sse41)
  40. {
  41. #if HAVE_SSE41
  42. #include "../generic/dec_head.c"
  43. dec_loop_ssse3(&s, &slen, &o, &olen);
  44. #include "../generic/dec_tail.c"
  45. #else
  46. BASE64_DEC_STUB
  47. #endif
  48. }