123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- /*
- * Copyright (c) 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
- /* ****************************************
- * Dependencies
- ******************************************/
- #include "zstd_deps.h" /* size_t */
- #include <linux/zstd_errors.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
- ******************************************/
- #undef ERROR /* already defined on Visual Studio */
- #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); }
- /* check and forward error code */
- #define CHECK_V_F(e, f) size_t const e = f; if (ERR_isError(e)) return e
- #define CHECK_F(f) { CHECK_V_F(_var_err__, f); }
- /*-****************************************
- * 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));
- }
- #endif /* ERROR_H_MODULE */
|