2017-08-18 23:52:05 +00:00
|
|
|
/*
|
2020-03-26 22:19:05 +00:00
|
|
|
* Copyright (c) 2016-2020, Yann Collet, Facebook, Inc.
|
2016-08-30 17:04:33 +00:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
2017-08-18 23:52:05 +00:00
|
|
|
* 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).
|
2017-09-08 07:09:23 +00:00
|
|
|
* You may select, at your option, one of the above-listed licenses.
|
2016-08-30 17:04:33 +00:00
|
|
|
*/
|
2015-10-18 21:18:32 +00:00
|
|
|
|
2016-01-21 14:38:47 +00:00
|
|
|
/* Note : this module is expected to remain private, do not expose it */
|
|
|
|
|
2015-10-18 21:18:32 +00:00
|
|
|
#ifndef ERROR_H_MODULE
|
|
|
|
#define ERROR_H_MODULE
|
|
|
|
|
|
|
|
#if defined (__cplusplus)
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2016-02-03 11:06:24 +00:00
|
|
|
/* ****************************************
|
|
|
|
* Dependencies
|
2015-10-30 10:21:50 +00:00
|
|
|
******************************************/
|
2016-02-03 11:06:24 +00:00
|
|
|
#include <stddef.h> /* size_t */
|
2016-10-11 23:41:09 +00:00
|
|
|
#include "zstd_errors.h" /* enum list */
|
2015-10-30 10:21:50 +00:00
|
|
|
|
|
|
|
|
2016-02-03 11:06:24 +00:00
|
|
|
/* ****************************************
|
2015-10-18 21:18:32 +00:00
|
|
|
* Compiler-specific
|
|
|
|
******************************************/
|
2016-01-21 14:38:47 +00:00
|
|
|
#if defined(__GNUC__)
|
|
|
|
# define ERR_STATIC static __attribute__((unused))
|
|
|
|
#elif defined (__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */)
|
2015-10-18 21:18:32 +00:00
|
|
|
# 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
|
|
|
|
|
|
|
|
|
2016-02-03 11:06:24 +00:00
|
|
|
/*-****************************************
|
2016-03-20 14:46:10 +00:00
|
|
|
* Customization (error_public.h)
|
2015-10-18 21:18:32 +00:00
|
|
|
******************************************/
|
2016-02-05 01:33:10 +00:00
|
|
|
typedef ZSTD_ErrorCode ERR_enum;
|
2015-10-18 21:18:32 +00:00
|
|
|
#define PREFIX(name) ZSTD_error_##name
|
|
|
|
|
2016-02-03 11:06:24 +00:00
|
|
|
|
|
|
|
/*-****************************************
|
|
|
|
* Error codes handling
|
|
|
|
******************************************/
|
2017-08-29 18:54:38 +00:00
|
|
|
#undef ERROR /* reported already defined on VS 2015 (Rich Geldreich) */
|
2017-08-26 00:44:32 +00:00
|
|
|
#define ERROR(name) ZSTD_ERROR(name)
|
|
|
|
#define ZSTD_ERROR(name) ((size_t)-PREFIX(name))
|
2015-10-18 21:18:32 +00:00
|
|
|
|
2016-01-21 14:38:47 +00:00
|
|
|
ERR_STATIC unsigned ERR_isError(size_t code) { return (code > ERROR(maxCode)); }
|
2015-10-18 21:18:32 +00:00
|
|
|
|
2016-05-10 15:47:11 +00:00
|
|
|
ERR_STATIC ERR_enum ERR_getErrorCode(size_t code) { if (!ERR_isError(code)) return (ERR_enum)0; return (ERR_enum) (0-code); }
|
2016-02-03 11:06:24 +00:00
|
|
|
|
2015-10-18 21:18:32 +00:00
|
|
|
|
2016-02-03 11:06:24 +00:00
|
|
|
/*-****************************************
|
2016-01-21 14:38:47 +00:00
|
|
|
* Error Strings
|
|
|
|
******************************************/
|
2015-10-18 21:18:32 +00:00
|
|
|
|
2016-10-12 00:24:50 +00:00
|
|
|
const char* ERR_getErrorString(ERR_enum code); /* error_private.c */
|
2015-10-18 21:18:32 +00:00
|
|
|
|
2016-05-10 15:47:11 +00:00
|
|
|
ERR_STATIC const char* ERR_getErrorName(size_t code)
|
|
|
|
{
|
|
|
|
return ERR_getErrorString(ERR_getErrorCode(code));
|
|
|
|
}
|
2015-10-18 21:18:32 +00:00
|
|
|
|
|
|
|
#if defined (__cplusplus)
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* ERROR_H_MODULE */
|