1f08c3bdfSopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later 2f08c3bdfSopenharmony_ci/* 3f08c3bdfSopenharmony_ci * Copyright (c) 2022 FUJITSU LIMITED. All rights reserved. 4f08c3bdfSopenharmony_ci * Author: Yang Xu <xuyang2018.jy@fujitsu.com> 5f08c3bdfSopenharmony_ci */ 6f08c3bdfSopenharmony_ci 7f08c3bdfSopenharmony_ci#ifndef LAPI_PIDFD_H__ 8f08c3bdfSopenharmony_ci#define LAPI_PIDFD_H__ 9f08c3bdfSopenharmony_ci 10f08c3bdfSopenharmony_ci#include <fcntl.h> 11f08c3bdfSopenharmony_ci#ifdef HAVE_SYS_PIDFD_H 12f08c3bdfSopenharmony_ci# include <sys/pidfd.h> 13f08c3bdfSopenharmony_ci#endif 14f08c3bdfSopenharmony_ci#include "config.h" 15f08c3bdfSopenharmony_ci#include "lapi/syscalls.h" 16f08c3bdfSopenharmony_ci 17f08c3bdfSopenharmony_ci#ifndef PIDFD_NONBLOCK 18f08c3bdfSopenharmony_ci#define PIDFD_NONBLOCK O_NONBLOCK 19f08c3bdfSopenharmony_ci#endif 20f08c3bdfSopenharmony_ci 21f08c3bdfSopenharmony_cistatic inline void pidfd_send_signal_supported(void) 22f08c3bdfSopenharmony_ci{ 23f08c3bdfSopenharmony_ci /* allow the tests to fail early */ 24f08c3bdfSopenharmony_ci tst_syscall(__NR_pidfd_send_signal); 25f08c3bdfSopenharmony_ci} 26f08c3bdfSopenharmony_ci 27f08c3bdfSopenharmony_ci#ifndef HAVE_PIDFD_SEND_SIGNAL 28f08c3bdfSopenharmony_cistatic inline int pidfd_send_signal(int pidfd, int sig, siginfo_t *info, 29f08c3bdfSopenharmony_ci unsigned int flags) 30f08c3bdfSopenharmony_ci{ 31f08c3bdfSopenharmony_ci return tst_syscall(__NR_pidfd_send_signal, pidfd, sig, info, flags); 32f08c3bdfSopenharmony_ci} 33f08c3bdfSopenharmony_ci#endif 34f08c3bdfSopenharmony_ci 35f08c3bdfSopenharmony_cistatic inline void pidfd_open_supported(void) 36f08c3bdfSopenharmony_ci{ 37f08c3bdfSopenharmony_ci /* allow the tests to fail early */ 38f08c3bdfSopenharmony_ci tst_syscall(__NR_pidfd_open); 39f08c3bdfSopenharmony_ci} 40f08c3bdfSopenharmony_ci 41f08c3bdfSopenharmony_ci#ifndef HAVE_PIDFD_OPEN 42f08c3bdfSopenharmony_cistatic inline int pidfd_open(pid_t pid, unsigned int flags) 43f08c3bdfSopenharmony_ci{ 44f08c3bdfSopenharmony_ci return tst_syscall(__NR_pidfd_open, pid, flags); 45f08c3bdfSopenharmony_ci} 46f08c3bdfSopenharmony_ci#endif 47f08c3bdfSopenharmony_ci 48f08c3bdfSopenharmony_cistatic inline void pidfd_getfd_supported(void) 49f08c3bdfSopenharmony_ci{ 50f08c3bdfSopenharmony_ci /* allow the tests to fail early */ 51f08c3bdfSopenharmony_ci tst_syscall(__NR_pidfd_getfd); 52f08c3bdfSopenharmony_ci} 53f08c3bdfSopenharmony_ci 54f08c3bdfSopenharmony_ci#ifndef HAVE_PIDFD_GETFD 55f08c3bdfSopenharmony_cistatic inline int pidfd_getfd(int pidfd, int targetfd, unsigned int flags) 56f08c3bdfSopenharmony_ci{ 57f08c3bdfSopenharmony_ci return tst_syscall(__NR_pidfd_getfd, pidfd, targetfd, flags); 58f08c3bdfSopenharmony_ci} 59f08c3bdfSopenharmony_ci#endif 60f08c3bdfSopenharmony_ci 61f08c3bdfSopenharmony_ci#endif /* LAPI_PIDFD_H__ */ 62