Util-Linux Archive mirror
 help / color / mirror / Atom feed
From: Markus Mayer <mmayer@broadcom.com>
To: util-linux mailing list <util-linux@vger.kernel.org>
Cc: Markus Mayer <mmayer@broadcom.com>
Subject: [PATCH] include: define pidfd syscalls if needed
Date: Tue,  1 Aug 2023 13:08:24 -0700	[thread overview]
Message-ID: <20230801200824.49768-1-mmayer@broadcom.com> (raw)

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 | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/include/pidfd-utils.h b/include/pidfd-utils.h
index 18f3c626ade9..ff0bc4c792fc 100644
--- a/include/pidfd-utils.h
+++ b/include/pidfd-utils.h
@@ -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>
-- 
2.40.1


             reply	other threads:[~2023-08-01 20:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-01 20:08 Markus Mayer [this message]
2023-08-03 10:16 ` [PATCH] include: define pidfd syscalls if needed Karel Zak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230801200824.49768-1-mmayer@broadcom.com \
    --to=mmayer@broadcom.com \
    --cc=util-linux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).