xref: /freebsd/sys/contrib/openzfs/module/zstd/lib/common/zstd_common.c (revision 187d8a3ce55a4e2d41fbe61465d5ff4ac0fc6bd5)
1 // SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0-only
2 /*
3  * Copyright (c) Meta Platforms, Inc. and affiliates.
4  * All rights reserved.
5  *
6  * This source code is licensed under both the BSD-style license (found in the
7  * LICENSE file in the root directory of this source tree) and the GPLv2 (found
8  * in the COPYING file in the root directory of this source tree).
9  * You may select, at your option, one of the above-listed licenses.
10  */
11 
12 
13 
14 /*-*************************************
15 *  Dependencies
16 ***************************************/
17 #define ZSTD_DEPS_NEED_MALLOC
18 #include "error_private.h"
19 #include "zstd_internal.h"
20 
21 
22 /*-****************************************
23 *  Version
24 ******************************************/
25 unsigned ZSTD_versionNumber(void) { return ZSTD_VERSION_NUMBER; }
26 
27 const char* ZSTD_versionString(void) { return ZSTD_VERSION_STRING; }
28 
29 
30 /*-****************************************
31 *  ZSTD Error Management
32 ******************************************/
33 #undef ZSTD_isError   /* defined within zstd_internal.h */
34 /*! ZSTD_isError() :
35  *  tells if a return value is an error code
36  *  symbol is required for external callers */
37 #if !defined(_STANDALONE)
38 unsigned ZSTD_isError(size_t code) __asm__("zfs_ZSTD_isError");
39 #endif
40 unsigned ZSTD_isError(size_t code) { return ERR_isError(code); }
41 
42 /*! ZSTD_getErrorName() :
43  *  provides error code string from function result (useful for debugging) */
44 const char* ZSTD_getErrorName(size_t code) { return ERR_getErrorName(code); }
45 
46 /*! ZSTD_getError() :
47  *  convert a `size_t` function result into a proper ZSTD_errorCode enum */
48 ZSTD_ErrorCode ZSTD_getErrorCode(size_t code) { return ERR_getErrorCode(code); }
49 
50 /*! ZSTD_getErrorString() :
51  *  provides error code string from enum */
52 const char* ZSTD_getErrorString(ZSTD_ErrorCode code) { return ERR_getErrorString(code); }
53