diff options
-rw-r--r-- | CMakeLists.txt | 3 | ||||
-rw-r--r-- | build/cmake/config.h.in | 4 | ||||
-rw-r--r-- | configure.ac | 4 | ||||
-rw-r--r-- | libarchive/archive_write_add_filter_zstd.c | 16 |
4 files changed, 17 insertions, 10 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 6dfdf966..1b38ffab 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -618,7 +618,8 @@ IF(ZSTD_FOUND) CMAKE_PUSH_CHECK_STATE() SET(CMAKE_REQUIRED_LIBRARIES ${ZSTD_LIBRARY}) SET(CMAKE_REQUIRED_INCLUDES ${ZSTD_INCLUDE_DIR}) - CHECK_FUNCTION_EXISTS(ZSTD_compressStream HAVE_LIBZSTD) + CHECK_FUNCTION_EXISTS(ZSTD_decompressStream HAVE_LIBZSTD) + CHECK_FUNCTION_EXISTS(ZSTD_compressStream HAVE_LIBZSTD_COMPRESSOR) # # TODO: test for static library. # diff --git a/build/cmake/config.h.in b/build/cmake/config.h.in index 5ddd2f33..ad799c02 100644 --- a/build/cmake/config.h.in +++ b/build/cmake/config.h.in @@ -738,6 +738,10 @@ typedef uint64_t uintmax_t; /* Define to 1 if you have the `zstd' library (-lzstd). */ #cmakedefine HAVE_LIBZSTD 1 +/* Define to 1 if you have the `zstd' library (-lzstd) with compression + support. */ +#cmakedefine HAVE_LIBZSTD_COMPRESSOR 1 + /* Define to 1 if you have the <limits.h> header file. */ #cmakedefine HAVE_LIMITS_H 1 diff --git a/configure.ac b/configure.ac index cb89c3ee..bd92e2cc 100644 --- a/configure.ac +++ b/configure.ac @@ -400,7 +400,9 @@ AC_ARG_WITH([zstd], if test "x$with_zstd" != "xno"; then AC_CHECK_HEADERS([zstd.h]) - AC_CHECK_LIB(zstd,ZSTD_compressStream) + AC_CHECK_LIB(zstd,ZSTD_decompressStream) + AC_CHECK_LIB(zstd,ZSTD_compressStream, + AC_DEFINE([HAVE_LIBZSTD_COMPRESSOR], [1], [Define to 1 if you have the `zstd' library (-lzstd) with compression support.])) fi AC_ARG_WITH([lzma], diff --git a/libarchive/archive_write_add_filter_zstd.c b/libarchive/archive_write_add_filter_zstd.c index 41e4c520..e85b7669 100644 --- a/libarchive/archive_write_add_filter_zstd.c +++ b/libarchive/archive_write_add_filter_zstd.c @@ -51,7 +51,7 @@ __FBSDID("$FreeBSD$"); struct private_data { int compression_level; int threads; -#if HAVE_ZSTD_H && HAVE_LIBZSTD +#if HAVE_ZSTD_H && HAVE_LIBZSTD_COMPRESSOR ZSTD_CStream *cstream; int64_t total_in; ZSTD_outBuffer out; @@ -77,7 +77,7 @@ static int archive_compressor_zstd_write(struct archive_write_filter *, const void *, size_t); static int archive_compressor_zstd_close(struct archive_write_filter *); static int archive_compressor_zstd_free(struct archive_write_filter *); -#if HAVE_ZSTD_H && HAVE_LIBZSTD +#if HAVE_ZSTD_H && HAVE_LIBZSTD_COMPRESSOR static int drive_compressor(struct archive_write_filter *, struct private_data *, int, const void *, size_t); #endif @@ -109,7 +109,7 @@ archive_write_add_filter_zstd(struct archive *_a) f->name = "zstd"; data->compression_level = CLEVEL_DEFAULT; data->threads = 0; -#if HAVE_ZSTD_H && HAVE_LIBZSTD +#if HAVE_ZSTD_H && HAVE_LIBZSTD_COMPRESSOR data->cstream = ZSTD_createCStream(); if (data->cstream == NULL) { free(data); @@ -136,7 +136,7 @@ static int archive_compressor_zstd_free(struct archive_write_filter *f) { struct private_data *data = (struct private_data *)f->data; -#if HAVE_ZSTD_H && HAVE_LIBZSTD +#if HAVE_ZSTD_H && HAVE_LIBZSTD_COMPRESSOR ZSTD_freeCStream(data->cstream); free(data->out.dst); #else @@ -189,7 +189,7 @@ archive_compressor_zstd_options(struct archive_write_filter *f, const char *key, if (string_is_numeric(value) != ARCHIVE_OK) { return (ARCHIVE_WARN); } -#if HAVE_ZSTD_H && HAVE_LIBZSTD +#if HAVE_ZSTD_H && HAVE_LIBZSTD_COMPRESSOR maximum = ZSTD_maxCLevel(); #if ZSTD_VERSION_NUMBER >= MINVER_MINCLEVEL if (ZSTD_versionNumber() >= MINVER_MINCLEVEL) { @@ -228,7 +228,7 @@ archive_compressor_zstd_options(struct archive_write_filter *f, const char *key, return (ARCHIVE_WARN); } -#if HAVE_ZSTD_H && HAVE_LIBZSTD +#if HAVE_ZSTD_H && HAVE_LIBZSTD_COMPRESSOR /* * Setup callback. */ @@ -353,7 +353,7 @@ drive_compressor(struct archive_write_filter *f, } } -#else /* HAVE_ZSTD_H && HAVE_LIBZSTD */ +#else /* HAVE_ZSTD_H && HAVE_LIBZSTD_COMPRESSOR */ static int archive_compressor_zstd_open(struct archive_write_filter *f) @@ -415,4 +415,4 @@ archive_compressor_zstd_close(struct archive_write_filter *f) return __archive_write_program_close(f, data->pdata); } -#endif /* HAVE_ZSTD_H && HAVE_LIBZSTD */ +#endif /* HAVE_ZSTD_H && HAVE_LIBZSTD_COMPRESSOR */ |