xref: /freebsd/sys/contrib/zstd/lib/zstd_errors.h (revision 5ff13fbc)
1*5ff13fbcSAllan Jude /*
2*5ff13fbcSAllan Jude  * Copyright (c) Yann Collet, Facebook, Inc.
3*5ff13fbcSAllan Jude  * All rights reserved.
4*5ff13fbcSAllan Jude  *
5*5ff13fbcSAllan Jude  * This source code is licensed under both the BSD-style license (found in the
6*5ff13fbcSAllan Jude  * LICENSE file in the root directory of this source tree) and the GPLv2 (found
7*5ff13fbcSAllan Jude  * in the COPYING file in the root directory of this source tree).
8*5ff13fbcSAllan Jude  * You may select, at your option, one of the above-listed licenses.
9*5ff13fbcSAllan Jude  */
10*5ff13fbcSAllan Jude 
11*5ff13fbcSAllan Jude #ifndef ZSTD_ERRORS_H_398273423
12*5ff13fbcSAllan Jude #define ZSTD_ERRORS_H_398273423
13*5ff13fbcSAllan Jude 
14*5ff13fbcSAllan Jude #if defined (__cplusplus)
15*5ff13fbcSAllan Jude extern "C" {
16*5ff13fbcSAllan Jude #endif
17*5ff13fbcSAllan Jude 
18*5ff13fbcSAllan Jude /*===== dependency =====*/
19*5ff13fbcSAllan Jude #include <stddef.h>   /* size_t */
20*5ff13fbcSAllan Jude 
21*5ff13fbcSAllan Jude 
22*5ff13fbcSAllan Jude /* =====   ZSTDERRORLIB_API : control library symbols visibility   ===== */
23*5ff13fbcSAllan Jude #ifndef ZSTDERRORLIB_VISIBILITY
24*5ff13fbcSAllan Jude #  if defined(__GNUC__) && (__GNUC__ >= 4)
25*5ff13fbcSAllan Jude #    define ZSTDERRORLIB_VISIBILITY __attribute__ ((visibility ("default")))
26*5ff13fbcSAllan Jude #  else
27*5ff13fbcSAllan Jude #    define ZSTDERRORLIB_VISIBILITY
28*5ff13fbcSAllan Jude #  endif
29*5ff13fbcSAllan Jude #endif
30*5ff13fbcSAllan Jude #if defined(ZSTD_DLL_EXPORT) && (ZSTD_DLL_EXPORT==1)
31*5ff13fbcSAllan Jude #  define ZSTDERRORLIB_API __declspec(dllexport) ZSTDERRORLIB_VISIBILITY
32*5ff13fbcSAllan Jude #elif defined(ZSTD_DLL_IMPORT) && (ZSTD_DLL_IMPORT==1)
33*5ff13fbcSAllan Jude #  define ZSTDERRORLIB_API __declspec(dllimport) ZSTDERRORLIB_VISIBILITY /* It isn't required but allows to generate better code, saving a function pointer load from the IAT and an indirect jump.*/
34*5ff13fbcSAllan Jude #else
35*5ff13fbcSAllan Jude #  define ZSTDERRORLIB_API ZSTDERRORLIB_VISIBILITY
36*5ff13fbcSAllan Jude #endif
37*5ff13fbcSAllan Jude 
38*5ff13fbcSAllan Jude /*-*********************************************
39*5ff13fbcSAllan Jude  *  Error codes list
40*5ff13fbcSAllan Jude  *-*********************************************
41*5ff13fbcSAllan Jude  *  Error codes _values_ are pinned down since v1.3.1 only.
42*5ff13fbcSAllan Jude  *  Therefore, don't rely on values if you may link to any version < v1.3.1.
43*5ff13fbcSAllan Jude  *
44*5ff13fbcSAllan Jude  *  Only values < 100 are considered stable.
45*5ff13fbcSAllan Jude  *
46*5ff13fbcSAllan Jude  *  note 1 : this API shall be used with static linking only.
47*5ff13fbcSAllan Jude  *           dynamic linking is not yet officially supported.
48*5ff13fbcSAllan Jude  *  note 2 : Prefer relying on the enum than on its value whenever possible
49*5ff13fbcSAllan Jude  *           This is the only supported way to use the error list < v1.3.1
50*5ff13fbcSAllan Jude  *  note 3 : ZSTD_isError() is always correct, whatever the library version.
51*5ff13fbcSAllan Jude  **********************************************/
52*5ff13fbcSAllan Jude typedef enum {
53*5ff13fbcSAllan Jude   ZSTD_error_no_error = 0,
54*5ff13fbcSAllan Jude   ZSTD_error_GENERIC  = 1,
55*5ff13fbcSAllan Jude   ZSTD_error_prefix_unknown                = 10,
56*5ff13fbcSAllan Jude   ZSTD_error_version_unsupported           = 12,
57*5ff13fbcSAllan Jude   ZSTD_error_frameParameter_unsupported    = 14,
58*5ff13fbcSAllan Jude   ZSTD_error_frameParameter_windowTooLarge = 16,
59*5ff13fbcSAllan Jude   ZSTD_error_corruption_detected = 20,
60*5ff13fbcSAllan Jude   ZSTD_error_checksum_wrong      = 22,
61*5ff13fbcSAllan Jude   ZSTD_error_dictionary_corrupted      = 30,
62*5ff13fbcSAllan Jude   ZSTD_error_dictionary_wrong          = 32,
63*5ff13fbcSAllan Jude   ZSTD_error_dictionaryCreation_failed = 34,
64*5ff13fbcSAllan Jude   ZSTD_error_parameter_unsupported   = 40,
65*5ff13fbcSAllan Jude   ZSTD_error_parameter_outOfBound    = 42,
66*5ff13fbcSAllan Jude   ZSTD_error_tableLog_tooLarge       = 44,
67*5ff13fbcSAllan Jude   ZSTD_error_maxSymbolValue_tooLarge = 46,
68*5ff13fbcSAllan Jude   ZSTD_error_maxSymbolValue_tooSmall = 48,
69*5ff13fbcSAllan Jude   ZSTD_error_stage_wrong       = 60,
70*5ff13fbcSAllan Jude   ZSTD_error_init_missing      = 62,
71*5ff13fbcSAllan Jude   ZSTD_error_memory_allocation = 64,
72*5ff13fbcSAllan Jude   ZSTD_error_workSpace_tooSmall= 66,
73*5ff13fbcSAllan Jude   ZSTD_error_dstSize_tooSmall = 70,
74*5ff13fbcSAllan Jude   ZSTD_error_srcSize_wrong    = 72,
75*5ff13fbcSAllan Jude   ZSTD_error_dstBuffer_null   = 74,
76*5ff13fbcSAllan Jude   /* following error codes are __NOT STABLE__, they can be removed or changed in future versions */
77*5ff13fbcSAllan Jude   ZSTD_error_frameIndex_tooLarge = 100,
78*5ff13fbcSAllan Jude   ZSTD_error_seekableIO          = 102,
79*5ff13fbcSAllan Jude   ZSTD_error_dstBuffer_wrong     = 104,
80*5ff13fbcSAllan Jude   ZSTD_error_srcBuffer_wrong     = 105,
81*5ff13fbcSAllan Jude   ZSTD_error_maxCode = 120  /* never EVER use this value directly, it can change in future versions! Use ZSTD_isError() instead */
82*5ff13fbcSAllan Jude } ZSTD_ErrorCode;
83*5ff13fbcSAllan Jude 
84*5ff13fbcSAllan Jude /*! ZSTD_getErrorCode() :
85*5ff13fbcSAllan Jude     convert a `size_t` function result into a `ZSTD_ErrorCode` enum type,
86*5ff13fbcSAllan Jude     which can be used to compare with enum list published above */
87*5ff13fbcSAllan Jude ZSTDERRORLIB_API ZSTD_ErrorCode ZSTD_getErrorCode(size_t functionResult);
88*5ff13fbcSAllan Jude ZSTDERRORLIB_API const char* ZSTD_getErrorString(ZSTD_ErrorCode code);   /**< Same as ZSTD_getErrorName, but using a `ZSTD_ErrorCode` enum argument */
89*5ff13fbcSAllan Jude 
90*5ff13fbcSAllan Jude 
91*5ff13fbcSAllan Jude #if defined (__cplusplus)
92*5ff13fbcSAllan Jude }
93*5ff13fbcSAllan Jude #endif
94*5ff13fbcSAllan Jude 
95*5ff13fbcSAllan Jude #endif /* ZSTD_ERRORS_H_398273423 */
96