11cb0ef41Sopenharmony_ci#include <stdint.h>
21cb0ef41Sopenharmony_ci#include <stddef.h>
31cb0ef41Sopenharmony_ci#include <stdlib.h>
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_ci#include "../../../include/libbase64.h"
61cb0ef41Sopenharmony_ci#include "../../tables/tables.h"
71cb0ef41Sopenharmony_ci#include "../../codecs.h"
81cb0ef41Sopenharmony_ci#include "config.h"
91cb0ef41Sopenharmony_ci#include "../../env.h"
101cb0ef41Sopenharmony_ci
111cb0ef41Sopenharmony_ci#if HAVE_SSSE3
121cb0ef41Sopenharmony_ci#include <tmmintrin.h>
131cb0ef41Sopenharmony_ci
141cb0ef41Sopenharmony_ci// Only enable inline assembly on supported compilers and on 64-bit CPUs.
151cb0ef41Sopenharmony_ci// 32-bit CPUs with SSSE3 support, such as low-end Atoms, only have eight XMM
161cb0ef41Sopenharmony_ci// registers, which is not enough to run the inline assembly.
171cb0ef41Sopenharmony_ci#ifndef BASE64_SSSE3_USE_ASM
181cb0ef41Sopenharmony_ci# if (defined(__GNUC__) || defined(__clang__)) && BASE64_WORDSIZE == 64
191cb0ef41Sopenharmony_ci#  define BASE64_SSSE3_USE_ASM 1
201cb0ef41Sopenharmony_ci# else
211cb0ef41Sopenharmony_ci#  define BASE64_SSSE3_USE_ASM 0
221cb0ef41Sopenharmony_ci# endif
231cb0ef41Sopenharmony_ci#endif
241cb0ef41Sopenharmony_ci
251cb0ef41Sopenharmony_ci#include "dec_reshuffle.c"
261cb0ef41Sopenharmony_ci#include "dec_loop.c"
271cb0ef41Sopenharmony_ci
281cb0ef41Sopenharmony_ci#if BASE64_SSSE3_USE_ASM
291cb0ef41Sopenharmony_ci# include "enc_loop_asm.c"
301cb0ef41Sopenharmony_ci#else
311cb0ef41Sopenharmony_ci# include "enc_reshuffle.c"
321cb0ef41Sopenharmony_ci# include "enc_translate.c"
331cb0ef41Sopenharmony_ci# include "enc_loop.c"
341cb0ef41Sopenharmony_ci#endif
351cb0ef41Sopenharmony_ci
361cb0ef41Sopenharmony_ci#endif	// HAVE_SSSE3
371cb0ef41Sopenharmony_ci
381cb0ef41Sopenharmony_ciBASE64_ENC_FUNCTION(ssse3)
391cb0ef41Sopenharmony_ci{
401cb0ef41Sopenharmony_ci#if HAVE_SSSE3
411cb0ef41Sopenharmony_ci	#include "../generic/enc_head.c"
421cb0ef41Sopenharmony_ci	enc_loop_ssse3(&s, &slen, &o, &olen);
431cb0ef41Sopenharmony_ci	#include "../generic/enc_tail.c"
441cb0ef41Sopenharmony_ci#else
451cb0ef41Sopenharmony_ci	BASE64_ENC_STUB
461cb0ef41Sopenharmony_ci#endif
471cb0ef41Sopenharmony_ci}
481cb0ef41Sopenharmony_ci
491cb0ef41Sopenharmony_ciBASE64_DEC_FUNCTION(ssse3)
501cb0ef41Sopenharmony_ci{
511cb0ef41Sopenharmony_ci#if HAVE_SSSE3
521cb0ef41Sopenharmony_ci	#include "../generic/dec_head.c"
531cb0ef41Sopenharmony_ci	dec_loop_ssse3(&s, &slen, &o, &olen);
541cb0ef41Sopenharmony_ci	#include "../generic/dec_tail.c"
551cb0ef41Sopenharmony_ci#else
561cb0ef41Sopenharmony_ci	BASE64_DEC_STUB
571cb0ef41Sopenharmony_ci#endif
581cb0ef41Sopenharmony_ci}
59