aboutsummaryrefslogtreecommitdiff
path: root/lib/zstd/error_private.h
diff options
context:
space:
mode:
authorMarek BehĂșn <marek.behun@nic.cz>2019-04-29 22:40:44 +0200
committerTom Rini <trini@konsulko.com>2019-05-05 08:48:50 -0400
commit8509f22aacf04ae892e28c2df3a79c1d72c39c25 (patch)
treebc9a4e343df2229b400df75c1054f855d1f88c16 /lib/zstd/error_private.h
parent83a486b6fdb9cc0d009de75d304fb51156425215 (diff)
lib: add Zstandard decompression support
Add the zstd library from Linux kernel (only decompression support). There are minimal changes to build with U-Boot, otherwise the files are identical to Linux commit dc35da16 from March 2018, the files had not been touched since in kernel. Also SPDX lincese tags were added. Signed-off-by: Marek BehĂșn <marek.behun@nic.cz>
Diffstat (limited to 'lib/zstd/error_private.h')
-rw-r--r--lib/zstd/error_private.h43
1 files changed, 43 insertions, 0 deletions
diff --git a/lib/zstd/error_private.h b/lib/zstd/error_private.h
new file mode 100644
index 0000000000..d4824e25b2
--- /dev/null
+++ b/lib/zstd/error_private.h
@@ -0,0 +1,43 @@
+/* SPDX-License-Identifier: (GPL-2.0 or BSD-3-Clause-Clear) */
+/**
+ * Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
+ * All rights reserved.
+ */
+
+/* Note : this module is expected to remain private, do not expose it */
+
+#ifndef ERROR_H_MODULE
+#define ERROR_H_MODULE
+
+/* ****************************************
+* Dependencies
+******************************************/
+#include <linux/types.h> /* size_t */
+#include <linux/zstd.h> /* enum list */
+
+/* ****************************************
+* Compiler-specific
+******************************************/
+#define ERR_STATIC static __attribute__((unused))
+
+/*-****************************************
+* Customization (error_public.h)
+******************************************/
+typedef ZSTD_ErrorCode ERR_enum;
+#define PREFIX(name) ZSTD_error_##name
+
+/*-****************************************
+* Error codes handling
+******************************************/
+#define ERROR(name) ((size_t)-PREFIX(name))
+
+ERR_STATIC unsigned ERR_isError(size_t code) { return (code > ERROR(maxCode)); }
+
+ERR_STATIC ERR_enum ERR_getErrorCode(size_t code)
+{
+ if (!ERR_isError(code))
+ return (ERR_enum)0;
+ return (ERR_enum)(0 - code);
+}
+
+#endif /* ERROR_H_MODULE */