aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/base64/avx2/codecs.h
diff options
context:
space:
mode:
authorDevtools Arcadia <arcadia-devtools@yandex-team.ru>2022-02-07 18:08:42 +0300
committerDevtools Arcadia <arcadia-devtools@mous.vla.yp-c.yandex.net>2022-02-07 18:08:42 +0300
commit1110808a9d39d4b808aef724c861a2e1a38d2a69 (patch)
treee26c9fed0de5d9873cce7e00bc214573dc2195b7 /contrib/libs/base64/avx2/codecs.h
downloadydb-1110808a9d39d4b808aef724c861a2e1a38d2a69.tar.gz
intermediate changes
ref:cde9a383711a11544ce7e107a78147fb96cc4029
Diffstat (limited to 'contrib/libs/base64/avx2/codecs.h')
-rw-r--r--contrib/libs/base64/avx2/codecs.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/contrib/libs/base64/avx2/codecs.h b/contrib/libs/base64/avx2/codecs.h
new file mode 100644
index 0000000000..16a285ac0b
--- /dev/null
+++ b/contrib/libs/base64/avx2/codecs.h
@@ -0,0 +1,35 @@
+#pragma once
+
+// Define machine endianness. This is for GCC:
+#if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
+ #define BASE64_AVX2_LITTLE_ENDIAN 1
+#else
+ #define BASE64_AVX2_LITTLE_ENDIAN 0
+#endif
+
+// This is for Clang:
+#ifdef __LITTLE_ENDIAN__
+ #define BASE64_AVX2_LITTLE_ENDIAN 1
+#endif
+
+#ifdef __BIG_ENDIAN__
+ #define BASE64_AVX2_LITTLE_ENDIAN 0
+#endif
+
+// Endian conversion functions
+#if BASE64_AVX2_LITTLE_ENDIAN
+ #define cpu_to_be32(x) __builtin_bswap32(x)
+ #define cpu_to_be64(x) __builtin_bswap64(x)
+ #define be32_to_cpu(x) __builtin_bswap32(x)
+ #define be64_to_cpu(x) __builtin_bswap64(x)
+#else
+ #define cpu_to_be32(x) (x)
+ #define cpu_to_be64(x) (x)
+ #define be32_to_cpu(x) (x)
+ #define be64_to_cpu(x) (x)
+#endif
+
+// These tables are used by all codecs
+// for fallback plain encoding/decoding:
+extern const uint8_t avx2_base64_table_enc[];
+extern const uint8_t avx2_base64_table_dec[];