diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2023-02-21 19:59:57 +0100 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2023-02-22 11:39:44 +0100 |
commit | 50b35193ec6f8f342364742a69a607e967b39b7f (patch) | |
tree | 3a87221efb9d6eec7e5d64d4dbc8aeaaa9176e53 /src/libsystemd/sd-journal | |
parent | 3f275dcb841bac7a29bba31c3b8b32981f6281fc (diff) | |
download | systemd-50b35193ec6f8f342364742a69a607e967b39b7f.tar.gz |
meson: merge our two valgrind configuration conditions into one
Most of the support for valgrind was under HAVE_VALGRIND_VALGRIND_H, i.e. we
would enable if the valgrind headers were found. The operations then we be
conditionalized on RUNNING_UNDER_VALGRIND.
But in a few places we had code which was conditionalized on VALGRIND, i.e. the
config option. I noticed because I compiled with -Dvalgrind=true on a machine
that didn't have valgrind.h, and the build failed because
RUNNING_UNDER_VALGRIND was not defined. My first idea was to add a check that
the header is present if the option is set, but it seems better to just remove
the option. The code to support valgrind is trivial, and if we're
!RUNNING_UNDER_VALGRIND, it has negligible cost. And the case of running under
valgrind is always some special testing/debugging mode, so we should just do
those extra steps to make valgrind output cleaner. Removing the option makes
things simpler and we don't have to think if something should be covered by the
one or the other configuration bit.
I had a vague recollection that in some places we used -Dvalgrind=true not
for valgrind support, but to enable additional cleanup under other sanitizers.
But that code would fail to build without the valgrind headers anyway, so
I'm not sure if that was still used. If there are uses like that, we can
extend the condition for cleanup_pools().
Diffstat (limited to 'src/libsystemd/sd-journal')
-rw-r--r-- | src/libsystemd/sd-journal/journal-send.c | 8 | ||||
-rw-r--r-- | src/libsystemd/sd-journal/journal-send.h | 5 | ||||
-rw-r--r-- | src/libsystemd/sd-journal/lookup3.c | 8 |
3 files changed, 9 insertions, 12 deletions
diff --git a/src/libsystemd/sd-journal/journal-send.c b/src/libsystemd/sd-journal/journal-send.c index 3b74d2246e..d0d29818c2 100644 --- a/src/libsystemd/sd-journal/journal-send.c +++ b/src/libsystemd/sd-journal/journal-send.c @@ -7,7 +7,7 @@ #include <sys/un.h> #include <unistd.h> #if HAVE_VALGRIND_VALGRIND_H -#include <valgrind/valgrind.h> +# include <valgrind/valgrind.h> #endif #define SD_JOURNAL_SUPPRESS_LOCATION @@ -77,9 +77,9 @@ int journal_fd_nonblock(bool nonblock) { return fd_nonblock(r, nonblock); } -#if VALGRIND void close_journal_fd(void) { - /* Be nice to valgrind. This is not atomic. This must be used only in tests. */ +#if HAVE_VALGRIND_VALGRIND_H + /* Be nice to valgrind. This is not atomic, so it is useful mainly for debugging. */ if (!RUNNING_ON_VALGRIND) return; @@ -92,8 +92,8 @@ void close_journal_fd(void) { safe_close(fd_plus_one - 1); fd_plus_one = 0; -} #endif +} _public_ int sd_journal_print(int priority, const char *format, ...) { int r; diff --git a/src/libsystemd/sd-journal/journal-send.h b/src/libsystemd/sd-journal/journal-send.h index 558d39a8c0..24315e249b 100644 --- a/src/libsystemd/sd-journal/journal-send.h +++ b/src/libsystemd/sd-journal/journal-send.h @@ -4,9 +4,4 @@ #include <stdbool.h> int journal_fd_nonblock(bool nonblock); - -#if VALGRIND void close_journal_fd(void); -#else -static inline void close_journal_fd(void) {} -#endif diff --git a/src/libsystemd/sd-journal/lookup3.c b/src/libsystemd/sd-journal/lookup3.c index 39967f21cd..a6a32e09c5 100644 --- a/src/libsystemd/sd-journal/lookup3.c +++ b/src/libsystemd/sd-journal/lookup3.c @@ -320,7 +320,9 @@ uint32_t jenkins_hashlittle( const void *key, size_t length, uint32_t initval) * still catch it and complain. The masking trick does make the hash * noticeably faster for short strings (like English words). */ -#if !VALGRIND && !HAS_FEATURE_ADDRESS_SANITIZER && !HAS_FEATURE_MEMORY_SANITIZER +#define VALGRIND_LIKE (HAVE_VALGRIND_VALGRIND_H || HAS_FEATURE_ADDRESS_SANITIZER || HAS_FEATURE_MEMORY_SANITIZER) + +#if !VALGRIND_LIKE switch(length) { @@ -505,7 +507,7 @@ void jenkins_hashlittle2( * still catch it and complain. The masking trick does make the hash * noticeably faster for short strings (like English words). */ -#if !VALGRIND && !HAS_FEATURE_ADDRESS_SANITIZER && !HAS_FEATURE_MEMORY_SANITIZER +#if !VALGRIND_LIKE switch(length) { @@ -681,7 +683,7 @@ uint32_t jenkins_hashbig( const void *key, size_t length, uint32_t initval) * still catch it and complain. The masking trick does make the hash * noticeably faster for short strings (like English words). */ -#if !VALGRIND && !HAS_FEATURE_ADDRESS_SANITIZER && !HAS_FEATURE_MEMORY_SANITIZER +#if !VALGRIND_LIKE switch(length) { |