]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
include: define pidfd syscalls if needed
authorMarkus Mayer <mmayer@broadcom.com>
Tue, 1 Aug 2023 20:08:24 +0000 (13:08 -0700)
committerKarel Zak <kzak@redhat.com>
Thu, 3 Aug 2023 10:04:12 +0000 (12:04 +0200)
If the kernel headers are too old to provide the pidfd syscall numbers,
let's define them ourselves. This can be helpful while cross-compiling.
The runtime environment may provide a kernel that is new enough to
handle the calls, even if the toolchain doesn't.

Signed-off-by: Markus Mayer <mmayer@broadcom.com>
include/pidfd-utils.h

index 18f3c626ade9d73c7748b3bd614a761faf392887..ff0bc4c792fc5e07bcecd4244142c0529eed52f0 100644 (file)
@@ -7,6 +7,20 @@
 
 #ifdef HAVE_SYS_SYSCALL_H
 # include <sys/syscall.h>
+
+/*
+ * If the kernel headers are too old to provide the syscall numbers, let's
+ * define them ourselves. This can be helpful while cross-compiling.
+ */
+#ifndef __NR_pidfd_send_signal
+#define __NR_pidfd_send_signal 424
+#define SYS_pidfd_send_signal __NR_pidfd_send_signal
+#endif
+#ifndef __NR_pidfd_open
+#define __NR_pidfd_open 434
+#define SYS_pidfd_open __NR_pidfd_open
+#endif
+
 # if defined(SYS_pidfd_send_signal) && defined(SYS_pidfd_open)
 #  ifdef HAVE_SYS_PIDFD_H
 #   include <sys/pidfd.h>