summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Matuška <martin@matuska.org>2022-01-03 11:39:15 +0100
committerGitHub <noreply@github.com>2022-01-03 11:39:15 +0100
commite374fbac9b62d35d8e4f3c32dd588a5040eacafe (patch)
tree95d348ad3168e86f58e08753f50b850490e96a5d
parent34462ad61f9c5aa1d2b22ea9b74b508bb8b1441e (diff)
parent406165fcb2a1b3a49983d9e68fcbee9d3640fbea (diff)
downloadlibarchive-e374fbac9b62d35d8e4f3c32dd588a5040eacafe.tar.gz
Merge pull request #1649 from petris/master
Support libzstd compiled with compressor disabled
-rw-r--r--CMakeLists.txt3
-rw-r--r--build/cmake/config.h.in4
-rw-r--r--configure.ac4
-rw-r--r--libarchive/archive_write_add_filter_zstd.c16
4 files changed, 17 insertions, 10 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a344a07f..c5c22a24 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 37fc7cfa..b7f8db7a 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 526f313b..85868ade 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 */