Debian Codegraph @

mypyc/lib-rt/base64/arch/sse41/codec.c

raw
1 #include <stdint.h>
2 #include <stddef.h>
3 #include <stdlib.h>
4
5 #include "libbase64.h"
6 #include "../../tables/tables.h"
7 #include "../../codecs.h"
8 #include "config.h"
9 #include "../../env.h"
10
11 #if HAVE_SSE41
12 #if defined(__clang__)
13 #pragma clang attribute push (__attribute__((target("sse4.1"))), apply_to=function)
14 #else
15 #pragma GCC target("sse4.1")
16 #endif
17 #include <smmintrin.h>
18
19 // Only enable inline assembly on supported compilers and on 64-bit CPUs.
20 #ifndef BASE64_SSE41_USE_ASM
21 # if (defined(__GNUC__) || defined(__clang__)) && BASE64_WORDSIZE == 64
22 # define BASE64_SSE41_USE_ASM 1
23 # else
24 # define BASE64_SSE41_USE_ASM 0
25 # endif
26 #endif
27
28 #include "../ssse3/dec_reshuffle.c"
29 #include "../ssse3/dec_loop.c"
30
31 #if BASE64_SSE41_USE_ASM
32 # include "../ssse3/enc_loop_asm.c"
33 #else
34 # include "../ssse3/enc_translate.c"
35 # include "../ssse3/enc_reshuffle.c"
36 # include "../ssse3/enc_loop.c"
37 #endif
38
39 #endif // HAVE_SSE41
40
41 void
42 base64_stream_encode_sse41 BASE64_ENC_PARAMS
43 {
44 #if HAVE_SSE41
45 #include "../generic/enc_head.c"
46 enc_loop_ssse3(&s, &slen, &o, &olen);
47 #include "../generic/enc_tail.c"
48 #else
49 base64_enc_stub(state, src, srclen, out, outlen);
50 #endif
51 }
52
53 int
54 base64_stream_decode_sse41 BASE64_DEC_PARAMS
55 {
56 #if HAVE_SSE41
57 #include "../generic/dec_head.c"
58 dec_loop_ssse3(&s, &slen, &o, &olen);
59 #include "../generic/dec_tail.c"
60 #if defined(__clang__)
61 #pragma clang attribute pop
62 #endif
63 #else
64 return base64_dec_stub(state, src, srclen, out, outlen);
65 #endif
66 }