blob: 8ebc95cbb2ab882027a3e6cc92cdd5abc1a0dee4 [file] [log] [blame]
Yann Collet32fb4072017-08-18 16:52:05 -07001/*
W. Felix Handte5d693cc2022-12-20 12:49:47 -05002 * Copyright (c) Meta Platforms, Inc. and affiliates.
Yann Collet4ded9e52016-08-30 10:04:33 -07003 * All rights reserved.
4 *
Yann Collet32fb4072017-08-18 16:52:05 -07005 * 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).
Yann Collet3128e032017-09-08 00:09:23 -07008 * You may select, at your option, one of the above-listed licenses.
Yann Collet4ded9e52016-08-30 10:04:33 -07009 */
Yann Collet977f1f32016-01-21 15:38:47 +010010
Yann Colleta17fd732016-10-11 16:41:09 -070011#ifndef ZSTD_ERRORS_H_398273423
12#define ZSTD_ERRORS_H_398273423
Yann Collet977f1f32016-01-21 15:38:47 +010013
14#if defined (__cplusplus)
15extern "C" {
16#endif
17
Nick Terrell8de46ab2016-12-16 13:27:30 -080018/* ===== ZSTDERRORLIB_API : control library symbols visibility ===== */
Nick Terrell358a2372022-12-15 15:46:34 -080019#ifndef ZSTDERRORLIB_VISIBLE
20 /* Backwards compatibility with old macro name */
21# ifdef ZSTDERRORLIB_VISIBILITY
22# define ZSTDERRORLIB_VISIBLE ZSTDERRORLIB_VISIBILITY
23# elif defined(__GNUC__) && (__GNUC__ >= 4) && !defined(__MINGW32__)
24# define ZSTDERRORLIB_VISIBLE __attribute__ ((visibility ("default")))
Nick Terrella1280402017-05-19 18:01:59 -070025# else
Nick Terrell358a2372022-12-15 15:46:34 -080026# define ZSTDERRORLIB_VISIBLE
Nick Terrella1280402017-05-19 18:01:59 -070027# endif
Nick Terrell8de46ab2016-12-16 13:27:30 -080028#endif
Nick Terrell358a2372022-12-15 15:46:34 -080029
30#ifndef ZSTDERRORLIB_HIDDEN
31# if defined(__GNUC__) && (__GNUC__ >= 4) && !defined(__MINGW32__)
32# define ZSTDERRORLIB_HIDDEN __attribute__ ((visibility ("hidden")))
33# else
34# define ZSTDERRORLIB_HIDDEN
35# endif
36#endif
37
Nick Terrell8de46ab2016-12-16 13:27:30 -080038#if defined(ZSTD_DLL_EXPORT) && (ZSTD_DLL_EXPORT==1)
Nick Terrell358a2372022-12-15 15:46:34 -080039# define ZSTDERRORLIB_API __declspec(dllexport) ZSTDERRORLIB_VISIBLE
Nick Terrell8de46ab2016-12-16 13:27:30 -080040#elif defined(ZSTD_DLL_IMPORT) && (ZSTD_DLL_IMPORT==1)
Nick Terrell358a2372022-12-15 15:46:34 -080041# define ZSTDERRORLIB_API __declspec(dllimport) ZSTDERRORLIB_VISIBLE /* It isn't required but allows to generate better code, saving a function pointer load from the IAT and an indirect jump.*/
Nick Terrell8de46ab2016-12-16 13:27:30 -080042#else
Nick Terrell358a2372022-12-15 15:46:34 -080043# define ZSTDERRORLIB_API ZSTDERRORLIB_VISIBLE
Nick Terrell8de46ab2016-12-16 13:27:30 -080044#endif
45
Yann Collet70163bf2018-02-20 12:54:49 -080046/*-*********************************************
47 * Error codes list
48 *-*********************************************
49 * Error codes _values_ are pinned down since v1.3.1 only.
50 * Therefore, don't rely on values if you may link to any version < v1.3.1.
51 *
52 * Only values < 100 are considered stable.
53 *
54 * note 1 : this API shall be used with static linking only.
55 * dynamic linking is not yet officially supported.
56 * note 2 : Prefer relying on the enum than on its value whenever possible
57 * This is the only supported way to use the error list < v1.3.1
58 * note 3 : ZSTD_isError() is always correct, whatever the library version.
59 **********************************************/
Yann Collet72bff502016-02-03 12:06:24 +010060typedef enum {
Yann Collet2bd64402017-07-13 17:12:16 -070061 ZSTD_error_no_error = 0,
62 ZSTD_error_GENERIC = 1,
63 ZSTD_error_prefix_unknown = 10,
64 ZSTD_error_version_unsupported = 12,
65 ZSTD_error_frameParameter_unsupported = 14,
66 ZSTD_error_frameParameter_windowTooLarge = 16,
67 ZSTD_error_corruption_detected = 20,
68 ZSTD_error_checksum_wrong = 22,
Yann Collet6a9c5252022-12-22 11:30:15 -080069 ZSTD_error_literals_headerWrong = 24,
Yann Collet2bd64402017-07-13 17:12:16 -070070 ZSTD_error_dictionary_corrupted = 30,
71 ZSTD_error_dictionary_wrong = 32,
72 ZSTD_error_dictionaryCreation_failed = 34,
73 ZSTD_error_parameter_unsupported = 40,
Elliot Gorokhovsky2a402622022-12-28 16:45:14 -050074 ZSTD_error_parameter_combination_unsupported = 41,
Yann Collet2bd64402017-07-13 17:12:16 -070075 ZSTD_error_parameter_outOfBound = 42,
76 ZSTD_error_tableLog_tooLarge = 44,
77 ZSTD_error_maxSymbolValue_tooLarge = 46,
78 ZSTD_error_maxSymbolValue_tooSmall = 48,
Yann Colletb339eff2024-12-19 09:45:28 -080079 ZSTD_error_cannotProduce_uncompressedBlock = 49,
Yann Colletb99ece92022-01-26 10:43:50 -080080 ZSTD_error_stabilityCondition_notRespected = 50,
Yann Collet2bd64402017-07-13 17:12:16 -070081 ZSTD_error_stage_wrong = 60,
82 ZSTD_error_init_missing = 62,
83 ZSTD_error_memory_allocation = 64,
Yann Collet89741652018-02-26 15:11:50 -080084 ZSTD_error_workSpace_tooSmall= 66,
Yann Collet2bd64402017-07-13 17:12:16 -070085 ZSTD_error_dstSize_tooSmall = 70,
86 ZSTD_error_srcSize_wrong = 72,
Yann Colletacd75a12018-10-29 15:03:57 -070087 ZSTD_error_dstBuffer_null = 74,
Yann Colletdb18a622023-01-25 13:07:53 -080088 ZSTD_error_noForwardProgress_destFull = 80,
89 ZSTD_error_noForwardProgress_inputEmpty = 82,
Yann Collet70163bf2018-02-20 12:54:49 -080090 /* following error codes are __NOT STABLE__, they can be removed or changed in future versions */
Yann Collet2bd64402017-07-13 17:12:16 -070091 ZSTD_error_frameIndex_tooLarge = 100,
92 ZSTD_error_seekableIO = 102,
Nick Terrella4ff2172020-04-27 17:42:03 -070093 ZSTD_error_dstBuffer_wrong = 104,
Nick Terrellc74be3f2020-10-12 13:45:33 -070094 ZSTD_error_srcBuffer_wrong = 105,
Elliot Gorokhovskyff42ed12023-02-09 17:01:17 -050095 ZSTD_error_sequenceProducer_failed = 106,
Danielle Rozenblit815d1d42023-01-23 09:58:34 -080096 ZSTD_error_externalSequences_invalid = 107,
Yann Collet94161952017-09-27 10:35:56 -070097 ZSTD_error_maxCode = 120 /* never EVER use this value directly, it can change in future versions! Use ZSTD_isError() instead */
Yann Collet982ffc72016-02-05 02:33:10 +010098} ZSTD_ErrorCode;
Yann Collet977f1f32016-01-21 15:38:47 +010099
Yann Collet3b0cff32017-07-13 18:58:30 -0700100ZSTDERRORLIB_API const char* ZSTD_getErrorString(ZSTD_ErrorCode code); /**< Same as ZSTD_getErrorName, but using a `ZSTD_ErrorCode` enum argument */
Yann Collet977f1f32016-01-21 15:38:47 +0100101
102
103#if defined (__cplusplus)
104}
105#endif
106
Yann Colleta17fd732016-10-11 16:41:09 -0700107#endif /* ZSTD_ERRORS_H_398273423 */