]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
build: use standard HAVE_ pattern for ZSTD compression check (#2111)
authorTim Kientzle <kientzle@acm.org>
Sun, 7 Apr 2024 21:44:37 +0000 (14:44 -0700)
committerMartin Matuska <martin@matuska.de>
Sun, 7 Apr 2024 21:45:21 +0000 (23:45 +0200)
Follow-on to #1649: this just changes the name of the preprocessor macro
to use the standard pattern HAVE_<function name>

In particular: newer ZSTD implementations have a growing variety of
compression functions; the standard pattern will make it easier to
select among those someday.

CMakeLists.txt
build/cmake/config.h.in
configure.ac
libarchive/archive_write_add_filter_zstd.c
libarchive/test/test_write_filter_zstd.c

index 3122d929cf2ea9e8164f37dfbf936af111d080fb..1cb975a3b425f9c33a1fd5c4d7504d1d2cd39103 100644 (file)
@@ -660,7 +660,7 @@ IF(ZSTD_FOUND)
   SET(CMAKE_REQUIRED_LIBRARIES ${ZSTD_LIBRARY})
   SET(CMAKE_REQUIRED_INCLUDES ${ZSTD_INCLUDE_DIR})
   CHECK_FUNCTION_EXISTS(ZSTD_decompressStream HAVE_LIBZSTD)
-  CHECK_FUNCTION_EXISTS(ZSTD_compressStream HAVE_LIBZSTD_COMPRESSOR)
+  CHECK_FUNCTION_EXISTS(ZSTD_compressStream HAVE_ZSTD_compressStream)
   #
   # TODO: test for static library.
   #
index 716657e3fff3c2f8f8628d94978e7b566565ac05..045a6b41657ed5d24e3159edff641b6533799db2 100644 (file)
@@ -774,9 +774,8 @@ 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 ZSTD_compressStream function. */
+#cmakedefine HAVE_ZSTD_compressStream 1
 
 /* Define to 1 if you have the <limits.h> header file. */
 #cmakedefine HAVE_LIMITS_H 1
index 93f7af94afaad68c9a404d810da176341f9b2aa6..29e9e8fbace38c4af56d389c5812bd0e0df210fe 100644 (file)
@@ -461,7 +461,7 @@ if test "x$with_zstd" != "xno"; then
   AC_CHECK_HEADERS([zstd.h])
   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.]))
+    AC_DEFINE([HAVE_ZSTD_compressStream], [1], [Define to 1 if you have the `zstd' library (-lzstd) with compression support.]))
 fi
 
 AC_ARG_WITH([lzma],
index 9a74085b5b7525e5de60db54cbe18642ba474bf1..94249accd08b61d8fe2ec4331320a91a02a70272 100644 (file)
@@ -53,7 +53,7 @@ struct private_data {
        int              compression_level;
        int              threads;
        int              long_distance;
-#if HAVE_ZSTD_H && HAVE_LIBZSTD_COMPRESSOR
+#if HAVE_ZSTD_H && HAVE_ZSTD_compressStream
        enum {
                running,
                finishing,
@@ -96,7 +96,7 @@ static int archive_compressor_zstd_write(struct archive_write_filter *,
 static int archive_compressor_zstd_flush(struct archive_write_filter *);
 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_COMPRESSOR
+#if HAVE_ZSTD_H && HAVE_ZSTD_compressStream
 static int drive_compressor(struct archive_write_filter *,
                    struct private_data *, int, const void *, size_t);
 #endif
@@ -130,7 +130,7 @@ archive_write_add_filter_zstd(struct archive *_a)
        data->compression_level = CLEVEL_DEFAULT;
        data->threads = 0;
        data->long_distance = 0;
-#if HAVE_ZSTD_H && HAVE_LIBZSTD_COMPRESSOR
+#if HAVE_ZSTD_H && HAVE_ZSTD_compressStream
        data->frame_per_file = 0;
        data->min_frame_in = 0;
        data->max_frame_in = SIZE_MAX;
@@ -164,7 +164,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_COMPRESSOR
+#if HAVE_ZSTD_H && HAVE_ZSTD_compressStream
        ZSTD_freeCStream(data->cstream);
        free(data->out.dst);
 #else
@@ -242,7 +242,7 @@ archive_compressor_zstd_options(struct archive_write_filter *f, const char *key,
                /* If we don't have the library, hard-code the max level */
                int minimum = CLEVEL_MIN;
                int maximum = CLEVEL_MAX;
-#if HAVE_ZSTD_H && HAVE_LIBZSTD_COMPRESSOR
+#if HAVE_ZSTD_H && HAVE_ZSTD_compressStream
                maximum = ZSTD_maxCLevel();
 #if ZSTD_VERSION_NUMBER >= MINVER_MINCLEVEL
                if (ZSTD_versionNumber() >= MINVER_MINCLEVEL) {
@@ -269,7 +269,7 @@ archive_compressor_zstd_options(struct archive_write_filter *f, const char *key,
                }
                data->threads = (int)threads;
                return (ARCHIVE_OK);
-#if HAVE_ZSTD_H && HAVE_LIBZSTD_COMPRESSOR
+#if HAVE_ZSTD_H && HAVE_ZSTD_compressStream
        } else if (strcmp(key, "frame-per-file") == 0) {
                data->frame_per_file = 1;
                return (ARCHIVE_OK);
@@ -304,7 +304,7 @@ archive_compressor_zstd_options(struct archive_write_filter *f, const char *key,
                if (string_to_number(value, &long_distance) != ARCHIVE_OK) {
                        return (ARCHIVE_WARN);
                }
-#if HAVE_ZSTD_H && HAVE_LIBZSTD_COMPRESSOR && ZSTD_VERSION_NUMBER >= MINVER_LONG
+#if HAVE_ZSTD_H && HAVE_ZSTD_compressStream && ZSTD_VERSION_NUMBER >= MINVER_LONG
                ZSTD_bounds bounds = ZSTD_cParam_getBounds(ZSTD_c_windowLog);
                if (ZSTD_isError(bounds.error)) {
                        int max_distance = ((int)(sizeof(size_t) == 4 ? 30 : 31));
@@ -329,7 +329,7 @@ archive_compressor_zstd_options(struct archive_write_filter *f, const char *key,
        return (ARCHIVE_WARN);
 }
 
-#if HAVE_ZSTD_H && HAVE_LIBZSTD_COMPRESSOR
+#if HAVE_ZSTD_H && HAVE_ZSTD_compressStream
 /*
  * Setup callback.
  */
@@ -485,7 +485,7 @@ fatal:
        return (ARCHIVE_FATAL);
 }
 
-#else /* HAVE_ZSTD_H && HAVE_LIBZSTD_COMPRESSOR */
+#else /* HAVE_ZSTD_H && HAVE_ZSTD_compressStream */
 
 static int
 archive_compressor_zstd_open(struct archive_write_filter *f)
@@ -547,4 +547,4 @@ archive_compressor_zstd_close(struct archive_write_filter *f)
        return __archive_write_program_close(f, data->pdata);
 }
 
-#endif /* HAVE_ZSTD_H && HAVE_LIBZSTD_COMPRESSOR */
+#endif /* HAVE_ZSTD_H && HAVE_ZSTD_compressStream */
index c68074e87b2002b2932765637b02582970e9f73c..da711f9e4bf9ab430e15b1b4804b8a074577d31d 100644 (file)
@@ -132,7 +132,7 @@ DEFINE_TEST(test_write_filter_zstd)
            archive_write_set_filter_option(a, NULL, "threads", "-1")); /* negative */
        assertEqualIntA(a, ARCHIVE_OK,
            archive_write_set_filter_option(a, NULL, "threads", "4"));
-#if HAVE_ZSTD_H && HAVE_LIBZSTD_COMPRESSOR
+#if HAVE_ZSTD_H && HAVE_ZSTD_compressStream
        /* frame-per-file: boolean */
        assertEqualIntA(a, ARCHIVE_OK,
            archive_write_set_filter_option(a, NULL, "frame-per-file", ""));