]>
git.proxmox.com Git - mirror_qemu.git/blob - bsd-user/freebsd/os-proc.h
04bce755e58b1d9c36b3e8888edf5a9c43949e12
2 * process related system call shims and definitions
4 * Copyright (c) 2013-14 Stacey D. Son
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
20 #ifndef BSD_USER_FREEBSD_OS_PROC_H
21 #define BSD_USER_FREEBSD_OS_PROC_H
23 #include <sys/param.h>
24 #include <sys/procctl.h>
25 #include <sys/signal.h>
26 #include <sys/types.h>
27 #include <sys/procdesc.h>
31 #include "target_arch_cpu.h"
33 pid_t
safe_wait4(pid_t wpid
, int *status
, int options
, struct rusage
*rusage
);
34 pid_t
safe_wait6(idtype_t idtype
, id_t id
, int *status
, int options
,
35 struct __wrusage
*wrusage
, siginfo_t
*infop
);
38 static inline abi_long
do_freebsd_execve(abi_ulong path_or_fd
, abi_ulong argp
,
42 return freebsd_exec_common(path_or_fd
, argp
, envp
, 0);
46 static inline abi_long
do_freebsd_fexecve(abi_ulong path_or_fd
, abi_ulong argp
,
50 return freebsd_exec_common(path_or_fd
, argp
, envp
, 1);
54 static inline abi_long
do_freebsd_wait4(abi_long arg1
, abi_ulong target_status
,
55 abi_long arg3
, abi_ulong target_rusage
)
59 struct rusage rusage
, *rusage_ptr
= NULL
;
64 ret
= get_errno(safe_wait4(arg1
, &status
, arg3
, rusage_ptr
));
69 if (target_status
!= 0) {
70 status
= host_to_target_waitstatus(status
);
71 if (put_user_s32(status
, target_status
) != 0) {
72 return -TARGET_EFAULT
;
75 if (target_rusage
!= 0) {
76 host_to_target_rusage(target_rusage
, &rusage
);
82 static inline abi_long
do_freebsd_wait6(void *cpu_env
, abi_long idtype
,
83 abi_long id1
, abi_long id2
,
84 abi_ulong target_status
, abi_long options
, abi_ulong target_wrusage
,
85 abi_ulong target_infop
, abi_ulong pad1
)
89 struct __wrusage wrusage
, *wrusage_ptr
= NULL
;
93 if (regpairs_aligned(cpu_env
) != 0) {
94 /* printf("shifting args\n"); */
95 /* 64-bit id is aligned, so shift all the arguments over by one */
98 target_status
= options
;
99 options
= target_wrusage
;
100 target_wrusage
= target_infop
;
104 if (target_wrusage
) {
105 wrusage_ptr
= &wrusage
;
107 ret
= get_errno(safe_wait6(idtype
, target_arg64(id1
, id2
),
108 &status
, options
, wrusage_ptr
, &info
));
113 if (target_status
!= 0) {
114 status
= host_to_target_waitstatus(status
);
115 if (put_user_s32(status
, target_status
) != 0) {
116 return -TARGET_EFAULT
;
119 if (target_wrusage
!= 0) {
120 host_to_target_wrusage(target_wrusage
, &wrusage
);
122 if (target_infop
!= 0) {
123 p
= lock_user(VERIFY_WRITE
, target_infop
, sizeof(target_siginfo_t
), 0);
125 return -TARGET_EFAULT
;
127 host_to_target_siginfo(p
, &info
);
128 unlock_user(p
, target_infop
, sizeof(target_siginfo_t
));
133 #endif /* BSD_USER_FREEBSD_OS_PROC_H */