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