diff mbox series

[v2,2/5] linux: Use compile_c_snippet to check linux/pidfd.h availability

Message ID 20220810172447.1502169-3-adhemerval.zanella@linaro.org
State New
Headers show
Series Fix sys/mount.h and kernel header tests | expand

Commit Message

Adhemerval Zanella Netto Aug. 10, 2022, 5:24 p.m. UTC
Instead of tying to a specific kernel version.

Checked on x86_64-linux-gnu.
---
 sysdeps/unix/sysv/linux/tst-pidfd-consts.py | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Comments

Florian Weimer Aug. 10, 2022, 5:38 p.m. UTC | #1
* Adhemerval Zanella:

> Instead of tying to a specific kernel version.
>
> Checked on x86_64-linux-gnu.
> ---
>  sysdeps/unix/sysv/linux/tst-pidfd-consts.py | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/sysdeps/unix/sysv/linux/tst-pidfd-consts.py b/sysdeps/unix/sysv/linux/tst-pidfd-consts.py
> index e207b55eef..d732173abd 100644
> --- a/sysdeps/unix/sysv/linux/tst-pidfd-consts.py
> +++ b/sysdeps/unix/sysv/linux/tst-pidfd-consts.py
> @@ -33,10 +33,12 @@ def main():
>                          help='C compiler (including options) to use')
>      args = parser.parse_args()
>  
> -    linux_version_headers = glibcsyscalls.linux_kernel_version(args.cc)
> -    # Linux started to provide pidfd.h with 5.10.
> -    if linux_version_headers < (5, 10):
> +    if glibcextract.compile_c_snippet(
> +            '#include <linux/pidfd.h>',
> +            args.cc).returncode != 0:
>          sys.exit (77)
> +
> +    linux_version_headers = glibcsyscalls.linux_kernel_version(args.cc)
>      linux_version_glibc = (5, 19)
>      sys.exit(glibcextract.compare_macro_consts(
>                  '#include <sys/pidfd.h>\n',

Looks fine once compile_c_snippet is there.

Reviewed-by: Florian Weimer <fweimer@redhat.com>

Thanks,
Florian
diff mbox series

Patch

diff --git a/sysdeps/unix/sysv/linux/tst-pidfd-consts.py b/sysdeps/unix/sysv/linux/tst-pidfd-consts.py
index e207b55eef..d732173abd 100644
--- a/sysdeps/unix/sysv/linux/tst-pidfd-consts.py
+++ b/sysdeps/unix/sysv/linux/tst-pidfd-consts.py
@@ -33,10 +33,12 @@  def main():
                         help='C compiler (including options) to use')
     args = parser.parse_args()
 
-    linux_version_headers = glibcsyscalls.linux_kernel_version(args.cc)
-    # Linux started to provide pidfd.h with 5.10.
-    if linux_version_headers < (5, 10):
+    if glibcextract.compile_c_snippet(
+            '#include <linux/pidfd.h>',
+            args.cc).returncode != 0:
         sys.exit (77)
+
+    linux_version_headers = glibcsyscalls.linux_kernel_version(args.cc)
     linux_version_glibc = (5, 19)
     sys.exit(glibcextract.compare_macro_consts(
                 '#include <sys/pidfd.h>\n',