[LTP] [PATCH 3/5] pidfd_getfd.h: add fallback

Yang Xu xuyang2018.jy@fujitsu.com
Wed Feb 16 11:04:26 CET 2022


Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
---
 configure.ac               |  1 +
 include/lapi/pidfd_getfd.h | 26 ++++++++++++++++++++++++++
 2 files changed, 27 insertions(+)
 create mode 100644 include/lapi/pidfd_getfd.h

diff --git a/configure.ac b/configure.ac
index 8d2c5b1c4..49499704e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -115,6 +115,7 @@ AC_CHECK_FUNCS_ONCE([ \
     open_tree \
     openat \
     openat2 \
+    pidfd_getfd \
     pidfd_open \
     pidfd_send_signal \
     pkey_mprotect \
diff --git a/include/lapi/pidfd_getfd.h b/include/lapi/pidfd_getfd.h
new file mode 100644
index 000000000..1f488a518
--- /dev/null
+++ b/include/lapi/pidfd_getfd.h
@@ -0,0 +1,26 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2022 FUJITSU LIMITED. All rights reserved.
+ * Author: Yang Xu <xuyang2018.jy@fujitsu.com>
+ */
+
+#ifndef LAPI_PIDFD_GETFD_H__
+#define LAPI_PIDFD_GETFD_H__
+
+#include "lapi/syscalls.h"
+#include "config.h"
+
+static inline void pidfd_getfd_supported(void)
+{
+	/* allow the tests to fail early */
+	tst_syscall(__NR_pidfd_getfd);
+}
+
+#ifndef HAVE_PIDFD_GETFD
+static inline int pidfd_getfd(int pidfd, int targetfd, unsigned int flags)
+{
+	return tst_syscall(__NR_pidfd_getfd, pidfd, targetfd, flags);
+}
+#endif
+
+#endif /* LAPI_PIDFD_GETFD_H__ */
-- 
2.23.0



More information about the ltp mailing list