EXTFS_LIBS
system_aio
zlib
+libzstd_LIBS
+libzstd_CFLAGS
FETCHER
FTP
FALSE
glib_LIBS
pixman_CFLAGS
pixman_LIBS
+libzstd_CFLAGS
+libzstd_LIBS
LIBNL3_CFLAGS
LIBNL3_LIBS
SYSTEMD_CFLAGS
pixman_CFLAGS
C compiler flags for pixman, overriding pkg-config
pixman_LIBS linker flags for pixman, overriding pkg-config
+ libzstd_CFLAGS
+ C compiler flags for libzstd, overriding pkg-config
+ libzstd_LIBS
+ linker flags for libzstd, overriding pkg-config
LIBNL3_CFLAGS
C compiler flags for LIBNL3, overriding pkg-config
LIBNL3_LIBS linker flags for LIBNL3, overriding pkg-config
+pkg_failed=no
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for libzstd" >&5
+$as_echo_n "checking for libzstd... " >&6; }
+
+if test -n "$libzstd_CFLAGS"; then
+ pkg_cv_libzstd_CFLAGS="$libzstd_CFLAGS"
+ elif test -n "$PKG_CONFIG"; then
+ if test -n "$PKG_CONFIG" && \
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libzstd\""; } >&5
+ ($PKG_CONFIG --exists --print-errors "libzstd") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; then
+ pkg_cv_libzstd_CFLAGS=`$PKG_CONFIG --cflags "libzstd" 2>/dev/null`
+ test "x$?" != "x0" && pkg_failed=yes
+else
+ pkg_failed=yes
+fi
+ else
+ pkg_failed=untried
+fi
+if test -n "$libzstd_LIBS"; then
+ pkg_cv_libzstd_LIBS="$libzstd_LIBS"
+ elif test -n "$PKG_CONFIG"; then
+ if test -n "$PKG_CONFIG" && \
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libzstd\""; } >&5
+ ($PKG_CONFIG --exists --print-errors "libzstd") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; then
+ pkg_cv_libzstd_LIBS=`$PKG_CONFIG --libs "libzstd" 2>/dev/null`
+ test "x$?" != "x0" && pkg_failed=yes
+else
+ pkg_failed=yes
+fi
+ else
+ pkg_failed=untried
+fi
+
+
+
+if test $pkg_failed = yes; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
+ _pkg_short_errors_supported=yes
+else
+ _pkg_short_errors_supported=no
+fi
+ if test $_pkg_short_errors_supported = yes; then
+ libzstd_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libzstd" 2>&1`
+ else
+ libzstd_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libzstd" 2>&1`
+ fi
+ # Put the nasty error message in config.log where it belongs
+ echo "$libzstd_PKG_ERRORS" >&5
+
+ true
+elif test $pkg_failed = untried; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+ true
+else
+ libzstd_CFLAGS=$pkg_cv_libzstd_CFLAGS
+ libzstd_LIBS=$pkg_cv_libzstd_LIBS
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+ zlib="$zlib -DHAVE_ZSTD $libzstd_CFLAGS $libzstd_LIBS"
+fi
+
ac_fn_c_check_header_mongrel "$LINENO" "ext2fs/ext2fs.h" "ac_cv_header_ext2fs_ext2fs_h" "$ac_includes_default"
#endif
+#if defined(HAVE_ZSTD)
+
+#include <zstd.h>
+
+static int xc_try_zstd_decode(
+ struct xc_dom_image *dom, void **blob, size_t *size)
+{
+ size_t outsize, insize, actual;
+ unsigned char *outbuf;
+
+ /* Magic, descriptor byte, and trailing size field. */
+ if ( *size <= 9 )
+ {
+ DOMPRINTF("ZSTD: insufficient input data");
+ return -1;
+ }
+
+ insize = *size - 4;
+ outsize = get_unaligned_le32(*blob + insize);
+
+ if ( xc_dom_kernel_check_size(dom, outsize) )
+ {
+ DOMPRINTF("ZSTD: output too large");
+ return -1;
+ }
+
+ outbuf = malloc(outsize);
+ if ( !outbuf )
+ {
+ DOMPRINTF("ZSTD: failed to alloc memory");
+ return -1;
+ }
+
+ actual = ZSTD_decompress(outbuf, outsize, *blob, insize);
+
+ if ( ZSTD_isError(actual) )
+ {
+ DOMPRINTF("ZSTD: error: %s", ZSTD_getErrorName(actual));
+ free(outbuf);
+ return -1;
+ }
+
+ if ( actual != outsize )
+ {
+ DOMPRINTF("ZSTD: got 0x%zx bytes instead of 0x%zx",
+ actual, outsize);
+ free(outbuf);
+ return -1;
+ }
+
+ if ( xc_dom_register_external(dom, outbuf, outsize) )
+ {
+ DOMPRINTF("ZSTD: error registering stream output");
+ free(outbuf);
+ return -1;
+ }
+
+ DOMPRINTF("%s: ZSTD decompress OK, 0x%zx -> 0x%zx",
+ __FUNCTION__, insize, outsize);
+
+ *blob = outbuf;
+ *size = outsize;
+
+ return 0;
+}
+
+#else /* !defined(HAVE_ZSTD) */
+
+static int xc_try_zstd_decode(
+ struct xc_dom_image *dom, void **blob, size_t *size)
+{
+ xc_dom_panic(dom->xch, XC_INTERNAL_ERROR,
+ "%s: ZSTD decompress support unavailable\n",
+ __FUNCTION__);
+ return -1;
+}
+
+#endif
+
#else /* __MINIOS__ */
int xc_try_bzip2_decode(struct xc_dom_image *dom, void **blob, size_t *size);
return -EINVAL;
}
}
+ else if ( check_magic(dom, "\x28\xb5\x2f\xfd", 4) )
+ {
+ ret = xc_try_zstd_decode(dom, &dom->kernel_blob, &dom->kernel_size);
+ if ( ret < 0 )
+ {
+ xc_dom_panic(dom->xch, XC_INVALID_KERNEL,
+ "%s unable to ZSTD decompress kernel",
+ __FUNCTION__);
+ return -EINVAL;
+ }
+ }
else if ( check_magic(dom, "\135\000", 2) )
{
ret = xc_try_lzma_decode(dom, &dom->kernel_blob, &dom->kernel_size);
#include "huf.h"
#include "mem.h" /* low level memory routines */
#include "zstd_internal.h"
-#include <xen/string.h> /* memcpy, memmove, memset */
#define ZSTD_PREFETCH(ptr) __builtin_prefetch(ptr, 0, 0)
BYTE headerBuffer[ZSTD_FRAMEHEADERSIZE_MAX];
}; /* typedef'd to ZSTD_DCtx within "zstd.h" */
-size_t INIT ZSTD_DCtxWorkspaceBound(void) { return ZSTD_ALIGN(sizeof(ZSTD_stack)) + ZSTD_ALIGN(sizeof(ZSTD_DCtx)); }
+STATIC size_t INIT ZSTD_DCtxWorkspaceBound(void)
+{
+ return ZSTD_ALIGN(sizeof(ZSTD_stack)) + ZSTD_ALIGN(sizeof(ZSTD_DCtx));
+}
-size_t INIT ZSTD_decompressBegin(ZSTD_DCtx *dctx)
+STATIC size_t INIT ZSTD_decompressBegin(ZSTD_DCtx *dctx)
{
dctx->expected = ZSTD_frameHeaderSize_prefix;
dctx->stage = ZSTDds_getFrameHeaderSize;
return 0;
}
-ZSTD_DCtx *INIT ZSTD_createDCtx_advanced(ZSTD_customMem customMem)
+STATIC ZSTD_DCtx *INIT ZSTD_createDCtx_advanced(ZSTD_customMem customMem)
{
ZSTD_DCtx *dctx;
return dctx;
}
-ZSTD_DCtx *INIT ZSTD_initDCtx(void *workspace, size_t workspaceSize)
+STATIC ZSTD_DCtx *INIT ZSTD_initDCtx(void *workspace, size_t workspaceSize)
{
ZSTD_customMem const stackMem = ZSTD_initStack(workspace, workspaceSize);
return ZSTD_createDCtx_advanced(stackMem);
return 0; /* reserved as a potential error code in the future */
}
+#ifdef BUILD_DEAD_CODE
void INIT ZSTD_copyDCtx(ZSTD_DCtx *dstDCtx, const ZSTD_DCtx *srcDCtx)
{
size_t const workSpaceSize = (ZSTD_BLOCKSIZE_ABSOLUTEMAX + WILDCOPY_OVERLENGTH) + ZSTD_frameHeaderSize_max;
memcpy(dstDCtx, srcDCtx, sizeof(ZSTD_DCtx) - workSpaceSize); /* no need to copy workspace */
}
+#endif
STATIC size_t ZSTD_findFrameCompressedSize(const void *src, size_t srcSize);
STATIC size_t ZSTD_decompressBegin_usingDict(ZSTD_DCtx *dctx, const void *dict,
* Decompression section
***************************************************************/
+#ifdef BUILD_DEAD_CODE
/*! ZSTD_isFrame() :
* Tells if the content of `buffer` starts with a valid Frame Identifier.
* Note : Frame Identifier is 4 bytes. If `size < 4`, @return will always be 0.
}
return 0;
}
+#endif
/** ZSTD_frameHeaderSize() :
* srcSize must be >= ZSTD_frameHeaderSize_prefix.
* @return : 0, `fparamsPtr` is correctly filled,
* >0, `srcSize` is too small, result is expected `srcSize`,
* or an error code, which can be tested using ZSTD_isError() */
-size_t INIT ZSTD_getFrameParams(ZSTD_frameParams *fparamsPtr, const void *src, size_t srcSize)
+STATIC size_t INIT ZSTD_getFrameParams(ZSTD_frameParams *fparamsPtr, const void *src, size_t srcSize)
{
const BYTE *ip = (const BYTE *)src;
return 0;
}
+#ifdef BUILD_DEAD_CODE
/** ZSTD_getFrameContentSize() :
* compatible with legacy mode
* @return : decompressed size of the single frame pointed to be `src` if known, otherwise
return totalDstSize;
}
}
+#endif /* BUILD_DEAD_CODE */
/** ZSTD_decodeFrameHeader() :
* `headerSize` must be the size provided by ZSTD_frameHeaderSize().
/*! ZSTD_getcBlockSize() :
* Provides the size of compressed block from block header `src` */
-size_t INIT ZSTD_getcBlockSize(const void *src, size_t srcSize, blockProperties_t *bpPtr)
+STATIC size_t INIT ZSTD_getcBlockSize(const void *src, size_t srcSize, blockProperties_t *bpPtr)
{
if (srcSize < ZSTD_blockHeaderSize)
return ERROR(srcSize_wrong);
/*! ZSTD_decodeLiteralsBlock() :
@return : nb of bytes read from src (< srcSize ) */
-size_t INIT ZSTD_decodeLiteralsBlock(ZSTD_DCtx *dctx, const void *src, size_t srcSize) /* note : srcSize < BLOCKSIZE */
+STATIC size_t INIT ZSTD_decodeLiteralsBlock(ZSTD_DCtx *dctx, const void *src, size_t srcSize) /* note : srcSize < BLOCKSIZE */
{
if (srcSize < MIN_CBLOCK_SIZE)
return ERROR(corruption_detected);
}
}
-size_t INIT ZSTD_decodeSeqHeaders(ZSTD_DCtx *dctx, int *nbSeqPtr, const void *src, size_t srcSize)
+STATIC size_t INIT ZSTD_decodeSeqHeaders(ZSTD_DCtx *dctx, int *nbSeqPtr, const void *src, size_t srcSize)
{
const BYTE *const istart = (const BYTE *const)src;
const BYTE *const iend = istart + srcSize;
}
}
+#ifdef BUILD_DEAD_CODE
size_t INIT ZSTD_decompressBlock(ZSTD_DCtx *dctx, void *dst, size_t dstCapacity, const void *src, size_t srcSize)
{
size_t dSize;
dctx->previousDstEnd = (const char *)blockStart + blockSize;
return blockSize;
}
+#endif /* BUILD_DEAD_CODE */
-size_t INIT ZSTD_generateNxBytes(void *dst, size_t dstCapacity, BYTE byte, size_t length)
+STATIC size_t INIT ZSTD_generateNxBytes(void *dst, size_t dstCapacity, BYTE byte, size_t length)
{
if (length > dstCapacity)
return ERROR(dstSize_tooSmall);
* `src` must point to the start of a ZSTD frame, ZSTD legacy frame, or skippable frame
* `srcSize` must be at least as large as the frame contained
* @return : the compressed size of the frame starting at `src` */
-size_t INIT ZSTD_findFrameCompressedSize(const void *src, size_t srcSize)
+STATIC size_t INIT ZSTD_findFrameCompressedSize(const void *src, size_t srcSize)
{
if (srcSize >= ZSTD_skippableHeaderSize && (ZSTD_readLE32(src) & 0xFFFFFFF0U) == ZSTD_MAGIC_SKIPPABLE_START) {
return ZSTD_skippableHeaderSize + ZSTD_readLE32((const BYTE *)src + 4);
return (BYTE *)dst - (BYTE *)dststart;
}
-size_t INIT ZSTD_decompress_usingDict(ZSTD_DCtx *dctx, void *dst, size_t dstCapacity, const void *src, size_t srcSize, const void *dict, size_t dictSize)
+STATIC size_t INIT ZSTD_decompress_usingDict(ZSTD_DCtx *dctx, void *dst, size_t dstCapacity, const void *src, size_t srcSize, const void *dict, size_t dictSize)
{
return ZSTD_decompressMultiFrame(dctx, dst, dstCapacity, src, srcSize, dict, dictSize, NULL);
}
-size_t INIT ZSTD_decompressDCtx(ZSTD_DCtx *dctx, void *dst, size_t dstCapacity, const void *src, size_t srcSize)
+STATIC size_t INIT ZSTD_decompressDCtx(ZSTD_DCtx *dctx, void *dst, size_t dstCapacity, const void *src, size_t srcSize)
{
return ZSTD_decompress_usingDict(dctx, dst, dstCapacity, src, srcSize, NULL, 0);
}
* Advanced Streaming Decompression API
* Bufferless and synchronous
****************************************/
-size_t INIT ZSTD_nextSrcSizeToDecompress(ZSTD_DCtx *dctx) { return dctx->expected; }
+STATIC size_t INIT ZSTD_nextSrcSizeToDecompress(ZSTD_DCtx *dctx)
+{
+ return dctx->expected;
+}
-ZSTD_nextInputType_e INIT ZSTD_nextInputType(ZSTD_DCtx *dctx)
+STATIC ZSTD_nextInputType_e INIT ZSTD_nextInputType(ZSTD_DCtx *dctx)
{
switch (dctx->stage) {
default: /* should not happen */
/** ZSTD_decompressContinue() :
* @return : nb of bytes generated into `dst` (necessarily <= `dstCapacity)
* or an error code, which can be tested using ZSTD_isError() */
-size_t INIT ZSTD_decompressContinue(ZSTD_DCtx *dctx, void *dst, size_t dstCapacity, const void *src, size_t srcSize)
+STATIC size_t INIT ZSTD_decompressContinue(ZSTD_DCtx *dctx, void *dst, size_t dstCapacity, const void *src, size_t srcSize)
{
/* Sanity check */
if (srcSize != dctx->expected)
return ZSTD_refDictContent(dctx, dict, dictSize);
}
-size_t INIT ZSTD_decompressBegin_usingDict(ZSTD_DCtx *dctx, const void *dict, size_t dictSize)
+STATIC size_t INIT ZSTD_decompressBegin_usingDict(ZSTD_DCtx *dctx, const void *dict, size_t dictSize)
{
CHECK_F(ZSTD_decompressBegin(dctx));
if (dict && dictSize)
ZSTD_customMem cMem;
}; /* typedef'd to ZSTD_DDict within "zstd.h" */
+#ifdef BUILD_DEAD_CODE
size_t INIT ZSTD_DDictWorkspaceBound(void) { return ZSTD_ALIGN(sizeof(ZSTD_stack)) + ZSTD_ALIGN(sizeof(ZSTD_DDict)); }
+#endif
static const void *INIT ZSTD_DDictDictContent(const ZSTD_DDict *ddict) { return ddict->dictContent; }
}
}
+#ifdef BUILD_DEAD_CODE
static size_t INIT ZSTD_loadEntropy_inDDict(ZSTD_DDict *ddict)
{
ddict->dictID = 0;
ZSTD_customMem const stackMem = ZSTD_initStack(workspace, workspaceSize);
return ZSTD_createDDict_advanced(dict, dictSize, 1, stackMem);
}
+#endif /* BUILD_DEAD_CODE */
size_t INIT ZSTD_freeDDict(ZSTD_DDict *ddict)
{
}
}
+#ifdef BUILD_DEAD_CODE
/*! ZSTD_getDictID_fromDict() :
* Provides the dictID stored within dictionary.
* if @return == 0, the dictionary is not conformant with Zstandard specification.
return 0;
return zfp.dictID;
}
+#endif /* BUILD_DEAD_CODE */
/*! ZSTD_decompress_usingDDict() :
* Decompression using a pre-digested Dictionary
* Use dictionary without significant overhead. */
-size_t INIT ZSTD_decompress_usingDDict(ZSTD_DCtx *dctx, void *dst, size_t dstCapacity, const void *src, size_t srcSize, const ZSTD_DDict *ddict)
+STATIC size_t INIT ZSTD_decompress_usingDDict(ZSTD_DCtx *dctx, void *dst, size_t dstCapacity, const void *src, size_t srcSize, const ZSTD_DDict *ddict)
{
/* pass content and size in case legacy frames are encountered */
return ZSTD_decompressMultiFrame(dctx, dst, dstCapacity, src, srcSize, NULL, 0, ddict);
U32 hostageByte;
}; /* typedef'd to ZSTD_DStream within "zstd.h" */
-size_t INIT ZSTD_DStreamWorkspaceBound(size_t maxWindowSize)
+STATIC size_t INIT ZSTD_DStreamWorkspaceBound(size_t maxWindowSize)
{
size_t const blockSize = MIN(maxWindowSize, ZSTD_BLOCKSIZE_ABSOLUTEMAX);
size_t const inBuffSize = blockSize;
return zds;
}
-ZSTD_DStream *INIT ZSTD_initDStream(size_t maxWindowSize, void *workspace, size_t workspaceSize)
+STATIC ZSTD_DStream *INIT ZSTD_initDStream(size_t maxWindowSize, void *workspace, size_t workspaceSize)
{
ZSTD_customMem const stackMem = ZSTD_initStack(workspace, workspaceSize);
ZSTD_DStream *zds = ZSTD_createDStream_advanced(stackMem);
return zds;
}
+#ifdef BUILD_DEAD_CODE
ZSTD_DStream *INIT ZSTD_initDStream_usingDDict(size_t maxWindowSize, const ZSTD_DDict *ddict, void *workspace, size_t workspaceSize)
{
ZSTD_DStream *zds = ZSTD_initDStream(maxWindowSize, workspace, workspaceSize);
}
return zds;
}
+#endif
size_t INIT ZSTD_freeDStream(ZSTD_DStream *zds)
{
/* *** Initialization *** */
+#ifdef BUILD_DEAD_CODE
size_t INIT ZSTD_DStreamInSize(void) { return ZSTD_BLOCKSIZE_ABSOLUTEMAX + ZSTD_blockHeaderSize; }
size_t INIT ZSTD_DStreamOutSize(void) { return ZSTD_BLOCKSIZE_ABSOLUTEMAX; }
+#endif
-size_t INIT ZSTD_resetDStream(ZSTD_DStream *zds)
+STATIC size_t INIT ZSTD_resetDStream(ZSTD_DStream *zds)
{
zds->stage = zdss_loadHeader;
zds->lhSize = zds->inPos = zds->outStart = zds->outEnd = 0;
return length;
}
-size_t INIT ZSTD_decompressStream(ZSTD_DStream *zds, ZSTD_outBuffer *output, ZSTD_inBuffer *input)
+STATIC size_t INIT ZSTD_decompressStream(ZSTD_DStream *zds, ZSTD_outBuffer *output, ZSTD_inBuffer *input)
{
const char *const istart = (const char *)(input->src) + input->pos;
const char *const iend = (const char *)(input->src) + input->size;