• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include <stdint.h>
2 #include <stddef.h>
3 #include <stdlib.h>
4 
5 #include "../../../include/libbase64.h"
6 #include "../../tables/tables.h"
7 #include "../../codecs.h"
8 #include "config.h"
9 #include "../../env.h"
10 
11 #if HAVE_SSSE3
12 #include <tmmintrin.h>
13 
14 // Only enable inline assembly on supported compilers and on 64-bit CPUs.
15 // 32-bit CPUs with SSSE3 support, such as low-end Atoms, only have eight XMM
16 // registers, which is not enough to run the inline assembly.
17 #ifndef BASE64_SSSE3_USE_ASM
18 # if (defined(__GNUC__) || defined(__clang__)) && BASE64_WORDSIZE == 64
19 #  define BASE64_SSSE3_USE_ASM 1
20 # else
21 #  define BASE64_SSSE3_USE_ASM 0
22 # endif
23 #endif
24 
25 #include "dec_reshuffle.c"
26 #include "dec_loop.c"
27 
28 #if BASE64_SSSE3_USE_ASM
29 # include "enc_loop_asm.c"
30 #else
31 # include "enc_reshuffle.c"
32 # include "enc_translate.c"
33 # include "enc_loop.c"
34 #endif
35 
36 #endif	// HAVE_SSSE3
37 
BASE64_ENC_FUNCTION(ssse3)38 BASE64_ENC_FUNCTION(ssse3)
39 {
40 #if HAVE_SSSE3
41 	#include "../generic/enc_head.c"
42 	enc_loop_ssse3(&s, &slen, &o, &olen);
43 	#include "../generic/enc_tail.c"
44 #else
45 	BASE64_ENC_STUB
46 #endif
47 }
48 
BASE64_DEC_FUNCTION(ssse3)49 BASE64_DEC_FUNCTION(ssse3)
50 {
51 #if HAVE_SSSE3
52 	#include "../generic/dec_head.c"
53 	dec_loop_ssse3(&s, &slen, &o, &olen);
54 	#include "../generic/dec_tail.c"
55 #else
56 	BASE64_DEC_STUB
57 #endif
58 }
59