1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
|
From 1df74208ea060b32e11b14e9b97049207ed03dd3 Mon Sep 17 00:00:00 2001
From: Bernd Schubert <bschubert@ddn.com>
Date: Thu, 24 Apr 2025 16:49:08 +0200
Subject: [PATCH] Fix meson function tests
Several meson tests were incorrectly failing
Checking for function "static_assert" : NO (cached)
Checking for function "pthread_setname_np" : NO (cached)
Check usable header "#include <linux/close_range.h>" : NO (cached)
These functions get now tested with compilation tests
and get found on my system.
Checking if "static_assert check" compiles: YES
Checking if "pthread_setname_np check" compiles: YES
Checking if "close_range check" compiles: YES
Signed-off-by: Bernd Schubert <bschubert@ddn.com>
Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
---
meson.build | 67 +++++++++++++++++++++++++++++++++++++++--------------
1 file changed, 49 insertions(+), 18 deletions(-)
diff --git a/meson.build b/meson.build
index ba551ed53..d1346d090 100644
--- a/meson.build
+++ b/meson.build
@@ -59,6 +59,8 @@ include_default = '''
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
+#include <assert.h> /* For static_assert */
+#include <pthread.h> /* For pthread_setname_np */
'''
args_default = [ '-D_GNU_SOURCE' ]
@@ -72,32 +74,61 @@ private_cfg.set_quoted('PACKAGE_VERSION', meson.project_version())
# Test for presence of some functions
test_funcs = [ 'fork', 'fstatat', 'openat', 'readlinkat', 'pipe2',
'splice', 'vmsplice', 'posix_fallocate', 'fdatasync',
- 'utimensat', 'copy_file_range', 'fallocate', 'static_assert',
- 'pthread_setname_np' ]
+ 'utimensat', 'copy_file_range', 'fallocate' ]
foreach func : test_funcs
private_cfg.set('HAVE_' + func.to_upper(),
cc.has_function(func, prefix: include_default, args: args_default))
endforeach
-private_cfg.set('HAVE_SETXATTR',
- cc.has_function('setxattr', prefix: '#include <sys/xattr.h>'))
-private_cfg.set('HAVE_ICONV',
- cc.has_function('iconv', prefix: '#include <iconv.h>'))
-private_cfg.set('HAVE_BACKTRACE',
- cc.has_function('backtrace', prefix: '#include <execinfo.h>'))
-# Test if headers exist
-private_cfg.set('HAVE_LINUX_CLOSE_RANGE_H',
- cc.check_header('#include <linux/close_range.h>'))
+# Special case checks that need custom code
+special_funcs = {
+ 'static_assert': '''
+ #include <assert.h>
+ static_assert(1, "test");
+ int main(void) { return 0; }
+ ''',
+ 'pthread_setname_np': '''
+ #include <pthread.h>
+ int main(void) {
+ pthread_t thread = pthread_self();
+ pthread_setname_np(thread, "test");
+ return 0;
+ }
+ ''',
+ 'close_range': '''
+ #include <unistd.h>
+ #include <fcntl.h>
+ #include <linux/close_range.h>
+ int main(void) {
+ unsigned int flags = CLOSE_RANGE_UNSHARE;
+ return close_range(3, ~0U, flags);
+ }
+ '''
+}
+
+foreach name, code : special_funcs
+ private_cfg.set('HAVE_' + name.to_upper(),
+ cc.compiles(code, args: ['-Werror'] + args_default,
+ name: name + ' check'))
+endforeach
+
+# Regular function checks
+private_cfg.set('HAVE_SETXATTR',
+ cc.has_function('setxattr', prefix: '#include <sys/xattr.h>'))
+private_cfg.set('HAVE_ICONV',
+ cc.has_function('iconv', prefix: '#include <iconv.h>'))
+private_cfg.set('HAVE_BACKTRACE',
+ cc.has_function('backtrace', prefix: '#include <execinfo.h>'))
-# Test if structs have specific member
+# Struct member checks
private_cfg.set('HAVE_STRUCT_STAT_ST_ATIM',
- cc.has_member('struct stat', 'st_atim',
- prefix: include_default,
- args: args_default))
+ cc.has_member('struct stat', 'st_atim',
+ prefix: include_default + '#include <sys/stat.h>',
+ args: args_default))
private_cfg.set('HAVE_STRUCT_STAT_ST_ATIMESPEC',
- cc.has_member('struct stat', 'st_atimespec',
- prefix: include_default,
- args: args_default))
+ cc.has_member('struct stat', 'st_atimespec',
+ prefix: include_default + '#include <sys/stat.h>',
+ args: args_default))
#
# Compiler configuration
|