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_AVX2
12#include <immintrin.h>
13
14// Only enable inline assembly on supported compilers and on 64-bit CPUs.
15#ifndef BASE64_AVX2_USE_ASM
16# if (defined(__GNUC__) || defined(__clang__)) && BASE64_WORDSIZE == 64
17#  define BASE64_AVX2_USE_ASM 1
18# else
19#  define BASE64_AVX2_USE_ASM 0
20# endif
21#endif
22
23#include "dec_reshuffle.c"
24#include "dec_loop.c"
25
26#if BASE64_AVX2_USE_ASM
27# include "enc_loop_asm.c"
28#else
29# include "enc_translate.c"
30# include "enc_reshuffle.c"
31# include "enc_loop.c"
32#endif
33
34#endif	// HAVE_AVX2
35
36BASE64_ENC_FUNCTION(avx2)
37{
38#if HAVE_AVX2
39	#include "../generic/enc_head.c"
40	enc_loop_avx2(&s, &slen, &o, &olen);
41	#include "../generic/enc_tail.c"
42#else
43	BASE64_ENC_STUB
44#endif
45}
46
47BASE64_DEC_FUNCTION(avx2)
48{
49#if HAVE_AVX2
50	#include "../generic/dec_head.c"
51	dec_loop_avx2(&s, &slen, &o, &olen);
52	#include "../generic/dec_tail.c"
53#else
54	BASE64_DEC_STUB
55#endif
56}
57