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