chiark / gitweb /
Turn VALGRIND variable into a meson configuration switch
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sun, 13 May 2018 20:28:24 +0000 (22:28 +0200)
committerSven Eden <yamakuzure@gmx.net>
Fri, 24 Aug 2018 14:47:08 +0000 (16:47 +0200)
Configuration through environment variable is inconvenient with meson, because
they cannot be convieniently changed and/or are not preserved during
reconfiguration (https://github.com/mesonbuild/meson/issues/1503).
This adds -Dvalgrind=true/false, which has the advantage that it can be set
at any time with meson configure -Dvalgrind=... and ninja will rebuild targets
as necessary. Additional minor advantages are better consistency with the
options for hashmap debugging, and typo avoidance with '#if' instead of '#ifdef'.

meson.build
meson_options.txt
src/basic/hashmap.c
src/basic/mempool.c
src/basic/mempool.h

index 6533e38c7b950bc15b4d2e7ccfbfa632066c9749..c18b5b496a4dab7e4ba44906f6611be42cd413ee 100644 (file)
@@ -905,6 +905,8 @@ conf.set10('ENABLE_DEBUG_MMAP_CACHE', enable_debug_mmap_cache)
 conf.set10('ENABLE_DEBUG_ELOGIND', enable_debug_elogind)
 #endif // 1
 
+conf.set10('VALGRIND', get_option('valgrind'))
+
 #####################################################################
 
 threads = dependency('threads')
@@ -1909,6 +1911,7 @@ exe = executable('elogind-inhibit',
 public_programs += [exe]
 executable('elogind-user-runtime-dir',
 executable('elogind-user-runtime-dir',
+executable('elogind-user-runtime-dir',
 executable('elogind-user-runtime-dir',
            user_runtime_dir_sources,
            include_directories : includes,
@@ -3277,6 +3280,7 @@ foreach tuple : [
 #         ['adm group',        get_option('adm-group')],
 #         ['wheel group',      get_option('wheel-group')],
 #         ['gshadow'],
+#         ['valgrind',         conf.get('VALGRIND') == 1],
 #else
         ['debug elogind'],
 #endif // 0
index fe8a5c9724d869c31b64f81fb55f5b40fe6eb7de..f39bed270c535e2608514c136aea265f28ac0fde 100644 (file)
@@ -74,6 +74,8 @@ option('kexec-path', type : 'string', description : 'path to kexec')
 #        description : 'enable extra debugging')
 # option('memory-accounting-default', type : 'boolean',
 #        description : 'enable MemoryAccounting= by default')
+# option('valgrind', type : 'boolean', value : false,
+#        description : 'do extra operations to avoid valgrind warnings')
 #else
 option('debug', type : 'string',
        description : 'enable extra debugging (elogind,hashmap,mmap-cache)')
index a70fd667c58b538a33e4ac70577987f71e6dfa41..95c15c26c763e9e0fd1141b62e433ff766832238 100644 (file)
@@ -281,7 +281,7 @@ static const struct hashmap_type_info hashmap_type_info[_HASHMAP_TYPE_MAX] = {
         },
 };
 
-#ifdef VALGRIND
+#if VALGRIND
 __attribute__((destructor)) static void cleanup_pools(void) {
         _cleanup_free_ char *t = NULL;
         int r;
index 4be4a3d38eb4b0f38937d9275812951a3ea37e15..2e55639e829bce475c9cef8313a3cb6761a2af29 100644 (file)
@@ -76,7 +76,7 @@ void mempool_free_tile(struct mempool *mp, void *p) {
         mp->freelist = p;
 }
 
-#ifdef VALGRIND
+#if VALGRIND
 
 void mempool_drop(struct mempool *mp) {
         struct pool *p = mp->first_pool;
index 5322fd480d39668952dd4e6854ecb11fb0bdf1b6..68249cd88118c8011d045db9196938bcb96bb7c1 100644 (file)
@@ -30,6 +30,6 @@ static struct mempool pool_name = { \
 }
 
 
-#ifdef VALGRIND
+#if VALGRIND
 void mempool_drop(struct mempool *mp);
 #endif