]>
git.proxmox.com Git - ceph.git/blob - ceph/src/zstd/contrib/linux-kernel/lib/zstd/error_private.h
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.
8 * This program is free software; you can redistribute it and/or modify it under
9 * the terms of the GNU General Public License version 2 as published by the
10 * Free Software Foundation. This program is dual-licensed; you may select
11 * either version 2 of the GNU General Public License ("GPL") or BSD license
15 /* Note : this module is expected to remain private, do not expose it */
17 #ifndef ERROR_H_MODULE
18 #define ERROR_H_MODULE
20 /* ****************************************
22 ******************************************/
23 #include <linux/types.h> /* size_t */
24 #include <linux/zstd.h> /* enum list */
26 /* ****************************************
28 ******************************************/
29 #define ERR_STATIC static __attribute__((unused))
31 /*-****************************************
32 * Customization (error_public.h)
33 ******************************************/
34 typedef ZSTD_ErrorCode ERR_enum
;
35 #define PREFIX(name) ZSTD_error_##name
37 /*-****************************************
38 * Error codes handling
39 ******************************************/
40 #define ERROR(name) ((size_t)-PREFIX(name))
42 ERR_STATIC
unsigned ERR_isError(size_t code
) { return (code
> ERROR(maxCode
)); }
44 ERR_STATIC ERR_enum
ERR_getErrorCode(size_t code
)
46 if (!ERR_isError(code
))
48 return (ERR_enum
)(0 - code
);
51 #endif /* ERROR_H_MODULE */