mirror of
https://github.com/systemd/systemd.git
synced 2025-01-25 10:04:04 +03:00
compression: add separate pre-processor definitions
Follow-up for cd3c6322db
journal-def.h should be self-contained too, as it represents the journal object ABI.
Duplicate the enums, as they also need to be in config.h for it to be self-contained,
and enums are not available to the preprocessor. Use an assert to ensure they don't
diverge.
This commit is contained in:
parent
3603f15171
commit
da13d2ca07
13
meson.build
13
meson.build
@ -1470,11 +1470,14 @@ elif compression == 'lz4' and not have_lz4
|
|||||||
elif compression == 'xz' and not have_xz
|
elif compression == 'xz' and not have_xz
|
||||||
error('default-compression=xz requires xz')
|
error('default-compression=xz requires xz')
|
||||||
endif
|
endif
|
||||||
conf.set('OBJECT_COMPRESSED_NONE', 0)
|
# These values are defined here so that config.h is self-contained, but they are also
|
||||||
conf.set('OBJECT_COMPRESSED_XZ', 1)
|
# re-defined (with different names to avoid conflits) in src/libsystemd/sd-journal/journal-def.h
|
||||||
conf.set('OBJECT_COMPRESSED_LZ4', 2)
|
# as that source file represents the journal object ABI, and we want that to be self-contained too.
|
||||||
conf.set('OBJECT_COMPRESSED_ZSTD', 4)
|
conf.set('COMPRESSION_NONE', 0)
|
||||||
conf.set('DEFAULT_COMPRESSION', 'OBJECT_COMPRESSED_@0@'.format(compression.to_upper()))
|
conf.set('COMPRESSION_XZ', 1)
|
||||||
|
conf.set('COMPRESSION_LZ4', 2)
|
||||||
|
conf.set('COMPRESSION_ZSTD', 4)
|
||||||
|
conf.set('DEFAULT_COMPRESSION', 'COMPRESSION_@0@'.format(compression.to_upper()))
|
||||||
|
|
||||||
want_xkbcommon = get_option('xkbcommon')
|
want_xkbcommon = get_option('xkbcommon')
|
||||||
if want_xkbcommon != 'false' and not skip_deps
|
if want_xkbcommon != 'false' and not skip_deps
|
||||||
|
@ -18,18 +18,18 @@ int compress_blob_zstd(const void *src, uint64_t src_size,
|
|||||||
static inline int compress_blob(const void *src, uint64_t src_size,
|
static inline int compress_blob(const void *src, uint64_t src_size,
|
||||||
void *dst, size_t dst_alloc_size, size_t *dst_size) {
|
void *dst, size_t dst_alloc_size, size_t *dst_size) {
|
||||||
int r;
|
int r;
|
||||||
#if DEFAULT_COMPRESSION == OBJECT_COMPRESSED_ZSTD
|
#if DEFAULT_COMPRESSION == COMPRESSION_ZSTD
|
||||||
r = compress_blob_zstd(src, src_size, dst, dst_alloc_size, dst_size);
|
r = compress_blob_zstd(src, src_size, dst, dst_alloc_size, dst_size);
|
||||||
if (r == 0)
|
if (r == 0)
|
||||||
return OBJECT_COMPRESSED_ZSTD;
|
return COMPRESSION_ZSTD;
|
||||||
#elif DEFAULT_COMPRESSION == OBJECT_COMPRESSED_LZ4
|
#elif DEFAULT_COMPRESSION == COMPRESSION_LZ4
|
||||||
r = compress_blob_lz4(src, src_size, dst, dst_alloc_size, dst_size);
|
r = compress_blob_lz4(src, src_size, dst, dst_alloc_size, dst_size);
|
||||||
if (r == 0)
|
if (r == 0)
|
||||||
return OBJECT_COMPRESSED_LZ4;
|
return COMPRESSION_LZ4;
|
||||||
#elif DEFAULT_COMPRESSION == OBJECT_COMPRESSED_XZ
|
#elif DEFAULT_COMPRESSION == COMPRESSION_XZ
|
||||||
r = compress_blob_xz(src, src_size, dst, dst_alloc_size, dst_size);
|
r = compress_blob_xz(src, src_size, dst, dst_alloc_size, dst_size);
|
||||||
if (r == 0)
|
if (r == 0)
|
||||||
return OBJECT_COMPRESSED_XZ;
|
return COMPRESSION_XZ;
|
||||||
#else
|
#else
|
||||||
r = -EOPNOTSUPP;
|
r = -EOPNOTSUPP;
|
||||||
#endif
|
#endif
|
||||||
@ -72,13 +72,13 @@ int decompress_stream_xz(int fdf, int fdt, uint64_t max_size);
|
|||||||
int decompress_stream_lz4(int fdf, int fdt, uint64_t max_size);
|
int decompress_stream_lz4(int fdf, int fdt, uint64_t max_size);
|
||||||
int decompress_stream_zstd(int fdf, int fdt, uint64_t max_size);
|
int decompress_stream_zstd(int fdf, int fdt, uint64_t max_size);
|
||||||
|
|
||||||
#if DEFAULT_COMPRESSION == OBJECT_COMPRESSED_ZSTD
|
#if DEFAULT_COMPRESSION == COMPRESSION_ZSTD
|
||||||
# define compress_stream compress_stream_zstd
|
# define compress_stream compress_stream_zstd
|
||||||
# define COMPRESSED_EXT ".zst"
|
# define COMPRESSED_EXT ".zst"
|
||||||
#elif DEFAULT_COMPRESSION == OBJECT_COMPRESSED_LZ4
|
#elif DEFAULT_COMPRESSION == COMPRESSION_LZ4
|
||||||
# define compress_stream compress_stream_lz4
|
# define compress_stream compress_stream_lz4
|
||||||
# define COMPRESSED_EXT ".lz4"
|
# define COMPRESSED_EXT ".lz4"
|
||||||
#elif DEFAULT_COMPRESSION == OBJECT_COMPRESSED_XZ
|
#elif DEFAULT_COMPRESSION == COMPRESSION_XZ
|
||||||
# define compress_stream compress_stream_xz
|
# define compress_stream compress_stream_xz
|
||||||
# define COMPRESSED_EXT ".xz"
|
# define COMPRESSED_EXT ".xz"
|
||||||
#else
|
#else
|
||||||
|
@ -43,12 +43,21 @@ typedef enum ObjectType {
|
|||||||
} ObjectType;
|
} ObjectType;
|
||||||
|
|
||||||
/* Object flags
|
/* Object flags
|
||||||
* The per-compression enums are defined in meson.build so that config.h is self-contained */
|
* The per-compression enums are also redefined in meson.build so that config.h is self-contained */
|
||||||
enum {
|
enum {
|
||||||
|
OBJECT_COMPRESSED_XZ = 1 << 0,
|
||||||
|
OBJECT_COMPRESSED_LZ4 = 1 << 1,
|
||||||
|
OBJECT_COMPRESSED_ZSTD = 1 << 2,
|
||||||
OBJECT_COMPRESSION_MASK = (OBJECT_COMPRESSED_XZ | OBJECT_COMPRESSED_LZ4 | OBJECT_COMPRESSED_ZSTD),
|
OBJECT_COMPRESSION_MASK = (OBJECT_COMPRESSED_XZ | OBJECT_COMPRESSED_LZ4 | OBJECT_COMPRESSED_ZSTD),
|
||||||
_OBJECT_COMPRESSED_MAX = OBJECT_COMPRESSION_MASK,
|
_OBJECT_COMPRESSED_MAX = OBJECT_COMPRESSION_MASK,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef COMPRESSION_XZ
|
||||||
|
assert_cc(OBJECT_COMPRESSED_XZ == COMPRESSION_XZ);
|
||||||
|
assert_cc(OBJECT_COMPRESSED_LZ4 == COMPRESSION_LZ4);
|
||||||
|
assert_cc(OBJECT_COMPRESSED_ZSTD == COMPRESSION_ZSTD);
|
||||||
|
#endif
|
||||||
|
|
||||||
struct ObjectHeader {
|
struct ObjectHeader {
|
||||||
uint8_t type;
|
uint8_t type;
|
||||||
uint8_t flags;
|
uint8_t flags;
|
||||||
|
@ -3359,11 +3359,11 @@ int journal_file_open(
|
|||||||
.open_flags = open_flags,
|
.open_flags = open_flags,
|
||||||
.writable = (open_flags & O_ACCMODE) != O_RDONLY,
|
.writable = (open_flags & O_ACCMODE) != O_RDONLY,
|
||||||
|
|
||||||
#if DEFAULT_COMPRESSION == OBJECT_COMPRESSED_ZSTD
|
#if DEFAULT_COMPRESSION == COMPRESSION_ZSTD
|
||||||
.compress_zstd = FLAGS_SET(file_flags, JOURNAL_COMPRESS),
|
.compress_zstd = FLAGS_SET(file_flags, JOURNAL_COMPRESS),
|
||||||
#elif DEFAULT_COMPRESSION == OBJECT_COMPRESSED_LZ4
|
#elif DEFAULT_COMPRESSION == COMPRESSION_LZ4
|
||||||
.compress_lz4 = FLAGS_SET(file_flags, JOURNAL_COMPRESS),
|
.compress_lz4 = FLAGS_SET(file_flags, JOURNAL_COMPRESS),
|
||||||
#elif DEFAULT_COMPRESSION == OBJECT_COMPRESSED_XZ
|
#elif DEFAULT_COMPRESSION == COMPRESSION_XZ
|
||||||
.compress_xz = FLAGS_SET(file_flags, JOURNAL_COMPRESS),
|
.compress_xz = FLAGS_SET(file_flags, JOURNAL_COMPRESS),
|
||||||
#endif
|
#endif
|
||||||
.compress_threshold_bytes = compress_threshold_bytes == UINT64_MAX ?
|
.compress_threshold_bytes = compress_threshold_bytes == UINT64_MAX ?
|
||||||
|
Loading…
x
Reference in New Issue
Block a user