diff --git a/meson.build b/meson.build index 827fdfc8cfe..08f322117f5 100644 --- a/meson.build +++ b/meson.build @@ -1190,36 +1190,38 @@ want_xz = get_option('xz') if want_xz != 'false' and not skip_deps libxz = dependency('liblzma', required : want_xz == 'true') - have = libxz.found() + have_xz = libxz.found() else - have = false + have_xz = false libxz = [] endif -conf.set10('HAVE_XZ', have) +conf.set10('HAVE_XZ', have_xz) want_lz4 = get_option('lz4') if want_lz4 != 'false' and not skip_deps liblz4 = dependency('liblz4', version : '>= 1.3.0', required : want_lz4 == 'true') - have = liblz4.found() + have_lz4 = liblz4.found() else - have = false + have_lz4 = false liblz4 = [] endif -conf.set10('HAVE_LZ4', have) +conf.set10('HAVE_LZ4', have_lz4) want_zstd = get_option('zstd') if want_zstd != 'false' and not skip_deps libzstd = dependency('libzstd', required : want_zstd == 'true', version : '>= 1.4.0') - have = libzstd.found() + have_zstd = libzstd.found() else - have = false + have_zstd = false libzstd = [] endif -conf.set10('HAVE_ZSTD', have) +conf.set10('HAVE_ZSTD', have_zstd) + +conf.set10('HAVE_COMPRESSION', have_xz or have_lz4 or have_zstd) want_xkbcommon = get_option('xkbcommon') if want_xkbcommon != 'false' and not skip_deps diff --git a/src/coredump/coredump.c b/src/coredump/coredump.c index d156d98efcd..1a41f260499 100644 --- a/src/coredump/coredump.c +++ b/src/coredump/coredump.c @@ -423,7 +423,7 @@ static int save_external_coredump( goto fail; } -#if HAVE_XZ || HAVE_LZ4 || HAVE_ZSTD +#if HAVE_COMPRESSION /* If we will remove the coredump anyway, do not compress. */ if (arg_compress && !maybe_remove_external_coredump(NULL, st.st_size)) { diff --git a/src/coredump/coredumpctl.c b/src/coredump/coredumpctl.c index eceb7927afa..c68fc6b4c99 100644 --- a/src/coredump/coredumpctl.c +++ b/src/coredump/coredumpctl.c @@ -824,7 +824,7 @@ static int save_core(sd_journal *j, FILE *file, char **path, bool *unlink_temp) } if (filename) { -#if HAVE_XZ || HAVE_LZ4 || HAVE_ZSTD +#if HAVE_COMPRESSION _cleanup_close_ int fdf; fdf = open(filename, O_RDONLY | O_CLOEXEC); diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c index ec2006bca23..9a08de1ba41 100644 --- a/src/journal/journal-file.c +++ b/src/journal/journal-file.c @@ -392,7 +392,7 @@ JournalFile* journal_file_close(JournalFile *f) { ordered_hashmap_free_free(f->chain_cache); -#if HAVE_XZ || HAVE_LZ4 || HAVE_ZSTD +#if HAVE_COMPRESSION free(f->compress_buffer); #endif @@ -1455,7 +1455,7 @@ int journal_file_find_data_object_with_hash( goto next; if (o->object.flags & OBJECT_COMPRESSION_MASK) { -#if HAVE_XZ || HAVE_LZ4 || HAVE_ZSTD +#if HAVE_COMPRESSION uint64_t l; size_t rsize = 0; @@ -1624,7 +1624,7 @@ static int journal_file_append_data( o->data.hash = htole64(hash); -#if HAVE_XZ || HAVE_LZ4 || HAVE_ZSTD +#if HAVE_COMPRESSION if (JOURNAL_FILE_COMPRESS(f) && size >= f->compress_threshold_bytes) { size_t rsize = 0; @@ -3852,7 +3852,7 @@ int journal_file_copy_entry(JournalFile *from, JournalFile *to, Object *o, uint6 return -E2BIG; if (o->object.flags & OBJECT_COMPRESSION_MASK) { -#if HAVE_XZ || HAVE_LZ4 || HAVE_ZSTD +#if HAVE_COMPRESSION size_t rsize = 0; r = decompress_blob(o->object.flags & OBJECT_COMPRESSION_MASK, diff --git a/src/journal/journal-file.h b/src/journal/journal-file.h index 37447e25e8d..f80bf5d26b1 100644 --- a/src/journal/journal-file.h +++ b/src/journal/journal-file.h @@ -107,7 +107,7 @@ typedef struct JournalFile { unsigned last_seen_generation; uint64_t compress_threshold_bytes; -#if HAVE_XZ || HAVE_LZ4 || HAVE_ZSTD +#if HAVE_COMPRESSION void *compress_buffer; size_t compress_buffer_size; #endif diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c index c9b75cc5ee4..853dd0c28b7 100644 --- a/src/journal/sd-journal.c +++ b/src/journal/sd-journal.c @@ -2327,7 +2327,7 @@ _public_ int sd_journal_get_data(sd_journal *j, const char *field, const void ** compression = o->object.flags & OBJECT_COMPRESSION_MASK; if (compression) { -#if HAVE_XZ || HAVE_LZ4 || HAVE_ZSTD +#if HAVE_COMPRESSION r = decompress_startswith(compression, o->data.payload, l, &f->compress_buffer, &f->compress_buffer_size, @@ -2394,7 +2394,7 @@ static int return_data(sd_journal *j, JournalFile *f, Object *o, const void **da compression = o->object.flags & OBJECT_COMPRESSION_MASK; if (compression) { -#if HAVE_XZ || HAVE_LZ4 || HAVE_ZSTD +#if HAVE_COMPRESSION size_t rsize; int r; diff --git a/src/journal/test-compress-benchmark.c b/src/journal/test-compress-benchmark.c index 1f9de5f7f68..35823a8da5e 100644 --- a/src/journal/test-compress-benchmark.c +++ b/src/journal/test-compress-benchmark.c @@ -17,7 +17,7 @@ typedef int (compress_t)(const void *src, uint64_t src_size, void *dst, typedef int (decompress_t)(const void *src, uint64_t src_size, void **dst, size_t *dst_alloc_size, size_t* dst_size, size_t dst_max); -#if HAVE_XZ || HAVE_LZ4 || HAVE_ZSTD +#if HAVE_COMPRESSION static usec_t arg_duration; static size_t arg_start; @@ -143,7 +143,7 @@ static void test_compress_decompress(const char* label, const char* type, #endif int main(int argc, char *argv[]) { -#if HAVE_XZ || HAVE_LZ4 || HAVE_ZSTD +#if HAVE_COMPRESSION test_setup_logging(LOG_INFO); if (argc >= 2) { diff --git a/src/journal/test-compress.c b/src/journal/test-compress.c index d34b3c6750f..0990f7604d5 100644 --- a/src/journal/test-compress.c +++ b/src/journal/test-compress.c @@ -44,7 +44,7 @@ typedef int (decompress_sw_t)(const void *src, uint64_t src_size, typedef int (compress_stream_t)(int fdf, int fdt, uint64_t max_bytes); typedef int (decompress_stream_t)(int fdf, int fdt, uint64_t max_size); -#if HAVE_XZ || HAVE_LZ4 || HAVE_ZSTD +#if HAVE_COMPRESSION _unused_ static void test_compress_decompress(const char *compression, compress_blob_t compress, decompress_blob_t decompress, @@ -265,7 +265,7 @@ static void test_lz4_decompress_partial(void) { #endif int main(int argc, char *argv[]) { -#if HAVE_XZ || HAVE_LZ4 || HAVE_ZSTD +#if HAVE_COMPRESSION _unused_ const char text[] = "text\0foofoofoofoo AAAA aaaaaaaaa ghost busters barbarbar FFF" "foofoofoofoo AAAA aaaaaaaaa ghost busters barbarbar FFF"; diff --git a/src/journal/test-journal.c b/src/journal/test-journal.c index c5596649ab5..5850bb8eaa3 100644 --- a/src/journal/test-journal.c +++ b/src/journal/test-journal.c @@ -157,7 +157,7 @@ static void test_empty(void) { (void) journal_file_close(f4); } -#if HAVE_XZ || HAVE_LZ4 || HAVE_ZSTD +#if HAVE_COMPRESSION static bool check_compressed(uint64_t compress_threshold, uint64_t data_size) { dual_timestamp ts; JournalFile *f; @@ -251,7 +251,7 @@ int main(int argc, char *argv[]) { test_non_empty(); test_empty(); -#if HAVE_XZ || HAVE_LZ4 || HAVE_ZSTD +#if HAVE_COMPRESSION test_min_compress_size(); #endif