2 * Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
5 * This source code is licensed under the BSD-style license found in the
6 * LICENSE file in the root directory of https://github.com/facebook/zstd.
7 * An additional grant of patent rights can be found in the PATENTS file in the
10 * This program is free software; you can redistribute it and/or modify it under
11 * the terms of the GNU General Public License version 2 as published by the
12 * Free Software Foundation. This program is dual-licensed; you may select
13 * either version 2 of the GNU General Public License ("GPL") or BSD license
17 /* Note : this module is expected to remain private, do not expose it */
19 #ifndef ERROR_H_MODULE
20 #define ERROR_H_MODULE
22 /* ****************************************
24 ******************************************/
25 #include <linux/types.h> /* size_t */
26 #include <linux/zstd.h> /* enum list */
28 /* ****************************************
30 ******************************************/
31 #define ERR_STATIC static __attribute__((unused))
33 /*-****************************************
34 * Customization (error_public.h)
35 ******************************************/
36 typedef ZSTD_ErrorCode ERR_enum;
37 #define PREFIX(name) ZSTD_error_##name
39 /*-****************************************
40 * Error codes handling
41 ******************************************/
42 #define ERROR(name) ((size_t)-PREFIX(name))
44 ERR_STATIC unsigned ERR_isError(size_t code) { return (code > ERROR(maxCode)); }
46 ERR_STATIC ERR_enum ERR_getErrorCode(size_t code)
48 if (!ERR_isError(code))
50 return (ERR_enum)(0 - code);
53 #endif /* ERROR_H_MODULE */