ReactOS  0.4.14-dev-593-g1793dcc
error_private.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
3  * All rights reserved.
4  *
5  * This source code is licensed under both the BSD-style license (found in the
6  * LICENSE file in the root directory of this source tree) and the GPLv2 (found
7  * in the COPYING file in the root directory of this source tree).
8  * You may select, at your option, one of the above-listed licenses.
9  */
10 
11 /* Note : this module is expected to remain private, do not expose it */
12 
13 #ifndef ERROR_H_MODULE
14 #define ERROR_H_MODULE
15 
16 #if defined (__cplusplus)
17 extern "C" {
18 #endif
19 
20 
21 /* ****************************************
22 * Dependencies
23 ******************************************/
24 #include <stddef.h> /* size_t */
25 #include "zstd_errors.h" /* enum list */
26 
27 
28 /* ****************************************
29 * Compiler-specific
30 ******************************************/
31 #if defined(__GNUC__)
32 # define ERR_STATIC static __attribute__((unused))
33 #elif defined (__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */)
34 # define ERR_STATIC static inline
35 #elif defined(_MSC_VER)
36 # define ERR_STATIC static __inline
37 #else
38 # define ERR_STATIC static /* this version may generate warnings for unused static functions; disable the relevant warning */
39 #endif
40 
41 
42 /*-****************************************
43 * Customization (error_public.h)
44 ******************************************/
46 #define PREFIX(name) ZSTD_error_##name
47 
48 
49 /*-****************************************
50 * Error codes handling
51 ******************************************/
52 #undef ERROR /* reported already defined on VS 2015 (Rich Geldreich) */
53 #define ERROR(name) ZSTD_ERROR(name)
54 #define ZSTD_ERROR(name) ((size_t)-PREFIX(name))
55 
56 ERR_STATIC unsigned ERR_isError(size_t code) { return (code > ERROR(maxCode)); }
57 
58 ERR_STATIC ERR_enum ERR_getErrorCode(size_t code) { if (!ERR_isError(code)) return (ERR_enum)0; return (ERR_enum) (0-code); }
59 
60 
61 /*-****************************************
62 * Error Strings
63 ******************************************/
64 
65 const char* ERR_getErrorString(ERR_enum code); /* error_private.c */
66 
67 ERR_STATIC const char* ERR_getErrorName(size_t code)
68 {
70 }
71 
72 #if defined (__cplusplus)
73 }
74 #endif
75 
76 #endif /* ERROR_H_MODULE */
#define ERROR(name)
Definition: error_private.h:53
ZSTD_ErrorCode ERR_enum
Definition: error_private.h:45
ZSTD_ErrorCode
Definition: zstd_errors.h:52
ERR_STATIC const char * ERR_getErrorName(size_t code)
Definition: error_private.h:67
ERR_STATIC ERR_enum ERR_getErrorCode(size_t code)
Definition: error_private.h:58
const char * ERR_getErrorString(ERR_enum code)
Definition: error_private.c:15
ERR_STATIC unsigned ERR_isError(size_t code)
Definition: error_private.h:56
#define ERR_STATIC
Definition: error_private.h:38
int code
Definition: i386-dis.c:3591