]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
meson: cleanup glibc header checkers
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 28 Feb 2025 16:05:05 +0000 (01:05 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 3 Mar 2025 17:24:49 +0000 (02:24 +0900)
meson.build

index 940210340163bfd24fdbd02975db9d455b12c11f..f31f6372470415f0a8aed579cc95d8de38220aaa 100644 (file)
@@ -565,85 +565,61 @@ long_max = cc.compute_int(
 assert(long_max > 100000)
 conf.set_quoted('LONG_MAX_STR', '@0@'.format(long_max))
 
-decl_headers = '''
-#include <dirent.h>
-#include <sched.h>
-#include <sys/mount.h>
-'''
-
-foreach decl : [
-                'struct mount_attr',
-                'struct dirent64',
-                'struct sched_attr',
-               ]
-
+foreach ident : [
+        ['struct dirent64',   '''##include <dirent.h>'''],      # for musl, but only for compile time check, see dirent-util.h
+        ['struct mount_attr', '''#include <sys/mount.h>'''],    # since glibc-2.36
+        ['struct sched_attr', '''#include <sched.h>'''],        # since glibc-2.41
+]
         # We get -1 if the size cannot be determined
-        have = cc.sizeof(decl, prefix : decl_headers, args : '-D_GNU_SOURCE') > 0
+        have = cc.sizeof(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE') > 0
 
-        if decl == 'struct mount_attr'
+        if ident[0] == 'struct mount_attr'
                 if have
                         want_linux_fs_h = false
                 else
-                        have = cc.sizeof(decl,
-                                         prefix : decl_headers + '#include <linux/fs.h>',
+                        have = cc.sizeof(ident[0],
+                                         prefix : ident[1] + '\n#include <linux/fs.h>',
                                          args : '-D_GNU_SOURCE') > 0
                         want_linux_fs_h = have
                 endif
         endif
 
-        conf.set10('HAVE_' + decl.underscorify().to_upper(), have)
+        conf.set10('HAVE_' + ident[0].underscorify().to_upper(), have)
 endforeach
 
 conf.set10('WANT_LINUX_FS_H', want_linux_fs_h)
 
 foreach ident : [
-        ['fchmodat2',         '''#include <stdlib.h>
-                                 #include <fcntl.h>'''],      # no known header declares fchmodat2
-        ['pivot_root',        '''#include <stdlib.h>
-                                 #include <unistd.h>'''],     # no known header declares pivot_root
-        ['ioprio_get',        '''#include <sched.h>'''],      # no known header declares ioprio_get
-        ['ioprio_set',        '''#include <sched.h>'''],      # no known header declares ioprio_set
-        ['sched_setattr',     '''#include <sched.h>'''],
-        ['kcmp',              '''#include <linux/kcmp.h>'''],
-        ['keyctl',            '''#include <sys/types.h>
-                                 #include <keyutils.h>'''],
-        ['bpf',               '''#include <sys/syscall.h>
-                                 #include <unistd.h>'''],
-        ['set_mempolicy',     '''#include <stdlib.h>
-                                 #include <unistd.h>'''],
-        ['get_mempolicy',     '''#include <stdlib.h>
-                                 #include <unistd.h>'''],
-        ['pidfd_send_signal', '''#include <stdlib.h>
-                                 #include <unistd.h>
-                                 #include <signal.h>
-                                 #include <sys/wait.h>
-                                 #include <sys/pidfd.h>'''],
-        ['pidfd_open',        '''#include <stdlib.h>
-                                 #include <unistd.h>
-                                 #include <signal.h>
-                                 #include <sys/wait.h>
-                                 #include <sys/pidfd.h>'''],
-        ['rt_tgsigqueueinfo', '''#include <stdlib.h>
-                                 #include <unistd.h>
-                                 #include <signal.h>
-                                 #include <sys/wait.h>'''],
-        ['mallinfo',          '''#include <malloc.h>'''],
-        ['mallinfo2',         '''#include <malloc.h>'''],
-        ['execveat',          '''#include <unistd.h>'''],
-        ['close_range',       '''#include <unistd.h>'''],
-        ['epoll_pwait2',      '''#include <sys/epoll.h>'''],
-        ['mount_setattr',     '''#include <sys/mount.h>'''],
-        ['move_mount',        '''#include <sys/mount.h>'''],
-        ['open_tree',         '''#include <sys/mount.h>'''],
-        ['fsopen',            '''#include <sys/mount.h>'''],
-        ['fsconfig',          '''#include <sys/mount.h>'''],
-        ['fsmount',           '''#include <sys/mount.h>'''],
-        ['getdents64',        '''#include <dirent.h>'''],
-        ['pidfd_spawn',       '''#include <spawn.h>'''],
-        ['strerrorname_np',   '''#include <string.h>'''],
-        ['quotactl_fd',       '''#include <sys/quota.h>'''],
-        ['setxattrat',        '''#include <sys/xattr.h>'''],  # no known header declares setxattrat
-        ['removexattrat',     '''#include <sys/xattr.h>'''],  # no known header declares removexattrat
+        ['set_mempolicy',     '''#include <sys/syscall.h>'''],  # declared at numaif.h provided by libnuma, which we do not use
+        ['get_mempolicy',     '''#include <sys/syscall.h>'''],  # declared at numaif.h provided by libnuma, which we do not use
+        ['getdents64',        '''#include <dirent.h>'''],       # since glibc-2.30, but check it for musl
+        ['strerrorname_np',   '''#include <string.h>'''],       # since glibc-2.32
+        ['mallinfo',          '''#include <malloc.h>'''],       # deprecated since glibc-2.33, but check it for musl
+        ['mallinfo2',         '''#include <malloc.h>'''],       # since glibc-2.33
+        ['execveat',          '''#include <unistd.h>'''],       # since glibc-2.34
+        ['close_range',       '''#include <unistd.h>'''],       # since glibc-2.34
+        ['epoll_pwait2',      '''#include <sys/epoll.h>'''],    # since glibc-2.35
+        ['fsconfig',          '''#include <sys/mount.h>'''],    # since glibc-2.36
+        ['fsmount',           '''#include <sys/mount.h>'''],    # since glibc-2.36
+        ['fsopen',            '''#include <sys/mount.h>'''],    # since glibc-2.36
+        ['mount_setattr',     '''#include <sys/mount.h>'''],    # since glibc-2.36
+        ['move_mount',        '''#include <sys/mount.h>'''],    # since glibc-2.36
+        ['open_tree',         '''#include <sys/mount.h>'''],    # since glibc-2.36
+        ['pidfd_open',        '''#include <sys/pidfd.h>'''],    # since glibc-2.36
+        ['pidfd_send_signal', '''#include <sys/pidfd.h>'''],    # since glibc-2.36
+        ['pidfd_spawn',       '''#include <spawn.h>'''],        # since glibc-2.39
+        ['sched_setattr',     '''#include <sched.h>'''],        # since glibc-2.41
+        ['ioprio_get',        '''#include <sched.h>'''],        # no known header declares ioprio_get
+        ['ioprio_set',        '''#include <sched.h>'''],        # no known header declares ioprio_set
+        ['rt_tgsigqueueinfo', '''#include <signal.h>'''],       # no known header declares rt_tgsigqueueinfo
+        ['quotactl_fd',       '''#include <sys/quota.h>'''],    # no known header declares quotactl_fd
+        ['fchmodat2',         '''#include <sys/stat.h>'''],     # no known header declares fchmodat2
+        ['bpf',               '''#include <sys/syscall.h>'''],  # no known header declares bpf
+        ['kcmp',              '''#include <sys/syscall.h>'''],  # no known header declares kcmp
+        ['keyctl',            '''#include <sys/syscall.h>'''],  # no known header declares keyctl
+        ['pivot_root',        '''#include <sys/syscall.h>'''],  # no known header declares pivot_root
+        ['setxattrat',        '''#include <sys/xattr.h>'''],    # no known header declares setxattrat
+        ['removexattrat',     '''#include <sys/xattr.h>'''],    # no known header declares removexattrat
 ]
 
         have = cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE')