summaryrefslogtreecommitdiffstats
path: root/Utilities/cmzstd/lib/common/error_private.h
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2019-03-13 14:46:32 (GMT)
committerBrad King <brad.king@kitware.com>2019-03-13 14:46:32 (GMT)
commitf92b4b52ebb335ce540966d7f198df3878f6f46f (patch)
tree4fe887bedbdff138072bfa6e0d1217b0756b2155 /Utilities/cmzstd/lib/common/error_private.h
parent9337cbfccab0b7a0984b837d71ff59543acb574d (diff)
parentfbaf65639ada9f3dc58337bf86c1cc036bc1694f (diff)
downloadCMake-f92b4b52ebb335ce540966d7f198df3878f6f46f.zip
CMake-f92b4b52ebb335ce540966d7f198df3878f6f46f.tar.gz
CMake-f92b4b52ebb335ce540966d7f198df3878f6f46f.tar.bz2
Merge branch 'upstream-zstd' into import-zstd
* upstream-zstd: zstd 2018-12-27 (470344d3)
Diffstat (limited to 'Utilities/cmzstd/lib/common/error_private.h')
-rw-r--r--Utilities/cmzstd/lib/common/error_private.h76
1 files changed, 76 insertions, 0 deletions
diff --git a/Utilities/cmzstd/lib/common/error_private.h b/Utilities/cmzstd/lib/common/error_private.h
new file mode 100644
index 0000000..0d2fa7e
--- /dev/null
+++ b/Utilities/cmzstd/lib/common/error_private.h
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under both the BSD-style license (found in the
+ * LICENSE file in the root directory of this source tree) and the GPLv2 (found
+ * in the COPYING file in the root directory of this source tree).
+ * You may select, at your option, one of the above-listed licenses.
+ */
+
+/* Note : this module is expected to remain private, do not expose it */
+
+#ifndef ERROR_H_MODULE
+#define ERROR_H_MODULE
+
+#if defined (__cplusplus)
+extern "C" {
+#endif
+
+
+/* ****************************************
+* Dependencies
+******************************************/
+#include <stddef.h> /* size_t */
+#include "zstd_errors.h" /* enum list */
+
+
+/* ****************************************
+* Compiler-specific
+******************************************/
+#if defined(__GNUC__)
+# define ERR_STATIC static __attribute__((unused))
+#elif defined (__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */)
+# define ERR_STATIC static inline
+#elif defined(_MSC_VER)
+# define ERR_STATIC static __inline
+#else
+# define ERR_STATIC static /* this version may generate warnings for unused static functions; disable the relevant warning */
+#endif
+
+
+/*-****************************************
+* Customization (error_public.h)
+******************************************/
+typedef ZSTD_ErrorCode ERR_enum;
+#define PREFIX(name) ZSTD_error_##name
+
+
+/*-****************************************
+* Error codes handling
+******************************************/
+#undef ERROR /* reported already defined on VS 2015 (Rich Geldreich) */
+#define ERROR(name) ZSTD_ERROR(name)
+#define ZSTD_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); }
+
+
+/*-****************************************
+* Error Strings
+******************************************/
+
+const char* ERR_getErrorString(ERR_enum code); /* error_private.c */
+
+ERR_STATIC const char* ERR_getErrorName(size_t code)
+{
+ return ERR_getErrorString(ERR_getErrorCode(code));
+}
+
+#if defined (__cplusplus)
+}
+#endif
+
+#endif /* ERROR_H_MODULE */