d0b38cbc3b
- Import zstd-1.3.6 from upstream - Add zstd's module.c file - Add the zstd module to Makefile.core.def Import zstd-1.3.6 from upstream [1]. Only the files need for decompression are imported. I used the latest zstd release, which includes patches [2] to build cleanly in GRUB. I included the script used to import zstd-1.3.6 below at the bottom of the commit message. Upstream zstd commit hash: 4fa456d7f12f8b27bd3b2f5dfd4f46898cb31c24 Upstream zstd commit name: Merge pull request #1354 from facebook/dev Zstd requires some posix headers, which it gets from posix_wrap. This can be checked by inspecting the .Po files generated by automake, which contain the header dependencies. After building run the command `cat grub-core/lib/zstd/.deps-core/*.Po` to see the dependencies [3]. The only OS dependencies are: - stddef.h, which is already a dependency in posix_wrap, and used for size_t by lzo and xz. - stdarg.h, which comes from the grub/misc.h header, and we don't use in zstd. All the types like uint64_t are typedefed to grub_uint64_t under the hood. The only exception is size_t, which comes from stddef.h. This is already the case for lzo and xz. I don't think there are any cross-compilation concerns, because cross-compilers provide their own system headers (and it would already be broken). [1] https://github.com/facebook/zstd/releases/tag/v1.3.6 [2] https://github.com/facebook/zstd/pull/1344 [3] https://gist.github.com/terrelln/7a16b92f5a1b3aecf980f944b4a966c4 ``` curl -L -O https://github.com/facebook/zstd/releases/download/v1.3.6/zstd-1.3.6.tar.gz curl -L -O https://github.com/facebook/zstd/releases/download/v1.3.6/zstd-1.3.6.tar.gz.sha256 sha256sum --check zstd-1.3.6.tar.gz.sha256 tar xzf zstd-1.3.6.tar.gz SRC_LIB="zstd-1.3.6/lib" DST_LIB="grub-core/lib/zstd" rm -rf $DST_LIB mkdir -p $DST_LIB cp $SRC_LIB/zstd.h $DST_LIB/ cp $SRC_LIB/common/*.[hc] $DST_LIB/ cp $SRC_LIB/decompress/*.[hc] $DST_LIB/ rm $DST_LIB/{pool.[hc],threading.[hc]} rm -rf zstd-1.3.6* echo SUCCESS! ``` Signed-off-by: Nick Terrell <terrelln@fb.com> Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
76 lines
2.3 KiB
C
76 lines
2.3 KiB
C
/*
|
|
* Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under both the BSD-style license (found in the
|
|
* LICENSE file in the root directory of this source tree) and the GPLv2 (found
|
|
* in the COPYING file in the root directory of this source tree).
|
|
* You may select, at your option, one of the above-listed licenses.
|
|
*/
|
|
|
|
/* Note : this module is expected to remain private, do not expose it */
|
|
|
|
#ifndef ERROR_H_MODULE
|
|
#define ERROR_H_MODULE
|
|
|
|
#if defined (__cplusplus)
|
|
extern "C" {
|
|
#endif
|
|
|
|
|
|
/* ****************************************
|
|
* Dependencies
|
|
******************************************/
|
|
#include <stddef.h> /* size_t */
|
|
#include "zstd_errors.h" /* enum list */
|
|
|
|
|
|
/* ****************************************
|
|
* Compiler-specific
|
|
******************************************/
|
|
#if defined(__GNUC__)
|
|
# define ERR_STATIC static __attribute__((unused))
|
|
#elif defined (__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */)
|
|
# define ERR_STATIC static inline
|
|
#elif defined(_MSC_VER)
|
|
# define ERR_STATIC static __inline
|
|
#else
|
|
# define ERR_STATIC static /* this version may generate warnings for unused static functions; disable the relevant warning */
|
|
#endif
|
|
|
|
|
|
/*-****************************************
|
|
* Customization (error_public.h)
|
|
******************************************/
|
|
typedef ZSTD_ErrorCode ERR_enum;
|
|
#define PREFIX(name) ZSTD_error_##name
|
|
|
|
|
|
/*-****************************************
|
|
* Error codes handling
|
|
******************************************/
|
|
#undef ERROR /* reported already defined on VS 2015 (Rich Geldreich) */
|
|
#define ERROR(name) ZSTD_ERROR(name)
|
|
#define ZSTD_ERROR(name) ((size_t)-PREFIX(name))
|
|
|
|
ERR_STATIC unsigned ERR_isError(size_t code) { return (code > ERROR(maxCode)); }
|
|
|
|
ERR_STATIC ERR_enum ERR_getErrorCode(size_t code) { if (!ERR_isError(code)) return (ERR_enum)0; return (ERR_enum) (0-code); }
|
|
|
|
|
|
/*-****************************************
|
|
* Error Strings
|
|
******************************************/
|
|
|
|
const char* ERR_getErrorString(ERR_enum code); /* error_private.c */
|
|
|
|
ERR_STATIC const char* ERR_getErrorName(size_t code)
|
|
{
|
|
return ERR_getErrorString(ERR_getErrorCode(code));
|
|
}
|
|
|
|
#if defined (__cplusplus)
|
|
}
|
|
#endif
|
|
|
|
#endif /* ERROR_H_MODULE */
|