From owner-p4-projects@FreeBSD.ORG Sun Oct 29 17:29:41 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id E8C1716A417; Sun, 29 Oct 2006 17:29:40 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C3E9516A403 for ; Sun, 29 Oct 2006 17:29:40 +0000 (UTC) (envelope-from netchild@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1831643D46 for ; Sun, 29 Oct 2006 17:29:35 +0000 (GMT) (envelope-from netchild@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id k9THTYIc070933 for ; Sun, 29 Oct 2006 17:29:34 GMT (envelope-from netchild@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id k9THTYvY070930 for perforce@freebsd.org; Sun, 29 Oct 2006 17:29:34 GMT (envelope-from netchild@freebsd.org) Date: Sun, 29 Oct 2006 17:29:34 GMT Message-Id: <200610291729.k9THTYvY070930@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to netchild@freebsd.org using -f From: Alexander Leidinger To: Perforce Change Reviews Cc: Subject: PERFORCE change 108671 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Oct 2006 17:29:41 -0000 http://perforce.freebsd.org/chv.cgi?CH=108671 Change 108671 by netchild@netchild_magellan on 2006/10/29 17:28:38 Add the linux rt_sigpending function from PR 93199. The PR is against 6.x, which is a little bit different. I changed the code to compile on -current, but didn't had time to test it or to review it word by word yet (so there may be dragons...). PR: 93199 Submitted by: Bruce Becker Affected files ... .. //depot/projects/linuxolator/src/sys/amd64/linux32/linux32_dummy.c#4 edit .. //depot/projects/linuxolator/src/sys/amd64/linux32/linux32_proto.h#10 edit .. //depot/projects/linuxolator/src/sys/amd64/linux32/linux32_syscall.h#10 edit .. //depot/projects/linuxolator/src/sys/amd64/linux32/linux32_sysent.c#9 edit .. //depot/projects/linuxolator/src/sys/amd64/linux32/syscalls.master#10 edit .. //depot/projects/linuxolator/src/sys/compat/linux/linux_signal.c#4 edit .. //depot/projects/linuxolator/src/sys/i386/linux/linux_dummy.c#4 edit .. //depot/projects/linuxolator/src/sys/i386/linux/linux_proto.h#9 edit .. //depot/projects/linuxolator/src/sys/i386/linux/linux_syscall.h#9 edit .. //depot/projects/linuxolator/src/sys/i386/linux/linux_sysent.c#9 edit .. //depot/projects/linuxolator/src/sys/i386/linux/syscalls.master#8 edit Differences ... ==== //depot/projects/linuxolator/src/sys/amd64/linux32/linux32_dummy.c#4 (text+ko) ==== @@ -53,7 +53,6 @@ DUMMY(sysfs); DUMMY(query_module); DUMMY(nfsservctl); -DUMMY(rt_sigtimedwait); DUMMY(rt_sigqueueinfo); DUMMY(capget); DUMMY(capset); ==== //depot/projects/linuxolator/src/sys/amd64/linux32/linux32_proto.h#10 (text+ko) ==== @@ -2,7 +2,7 @@ * System call prototypes. * * DO NOT EDIT-- this file is automatically generated. - * $FreeBSD: src/sys/amd64/linux32/linux32_proto.h,v 1.24 2006/10/28 11:24:38 netchild Exp $ + * $FreeBSD$ * created from FreeBSD: src/sys/amd64/linux32/syscalls.master,v 1.22 2006/10/28 10:59:59 netchild Exp */ @@ -547,7 +547,10 @@ char sigsetsize_l_[PADL_(l_size_t)]; l_size_t sigsetsize; char sigsetsize_r_[PADR_(l_size_t)]; }; struct linux_rt_sigtimedwait_args { - register_t dummy; + char mask_l_[PADL_(l_sigset_t *)]; l_sigset_t * mask; char mask_r_[PADR_(l_sigset_t *)]; + char ptr_l_[PADL_(l_siginfo_t *)]; l_siginfo_t * ptr; char ptr_r_[PADR_(l_siginfo_t *)]; + char timeout_l_[PADL_(struct l_timeval *)]; struct l_timeval * timeout; char timeout_r_[PADR_(struct l_timeval *)]; + char sigsetsize_l_[PADL_(l_size_t)]; l_size_t sigsetsize; char sigsetsize_r_[PADR_(l_size_t)]; }; struct linux_rt_sigqueueinfo_args { register_t dummy; ==== //depot/projects/linuxolator/src/sys/amd64/linux32/linux32_syscall.h#10 (text+ko) ==== @@ -2,7 +2,7 @@ * System call numbers. * * DO NOT EDIT-- this file is automatically generated. - * $FreeBSD: src/sys/amd64/linux32/linux32_syscall.h,v 1.24 2006/10/28 11:24:38 netchild Exp $ + * $FreeBSD$ * created from FreeBSD: src/sys/amd64/linux32/syscalls.master,v 1.22 2006/10/28 10:59:59 netchild Exp */ ==== //depot/projects/linuxolator/src/sys/amd64/linux32/linux32_sysent.c#9 (text+ko) ==== @@ -2,7 +2,7 @@ * System call switch table. * * DO NOT EDIT-- this file is automatically generated. - * $FreeBSD: src/sys/amd64/linux32/linux32_sysent.c,v 1.24 2006/10/28 11:24:38 netchild Exp $ + * $FreeBSD$ * created from FreeBSD: src/sys/amd64/linux32/syscalls.master,v 1.22 2006/10/28 10:59:59 netchild Exp */ @@ -197,7 +197,7 @@ { AS(linux_rt_sigaction_args), (sy_call_t *)linux_rt_sigaction, AUE_NULL, NULL, 0, 0 }, /* 174 = linux_rt_sigaction */ { AS(linux_rt_sigprocmask_args), (sy_call_t *)linux_rt_sigprocmask, AUE_NULL, NULL, 0, 0 }, /* 175 = linux_rt_sigprocmask */ { AS(linux_rt_sigpending_args), (sy_call_t *)linux_rt_sigpending, AUE_NULL, NULL, 0, 0 }, /* 176 = linux_rt_sigpending */ - { 0, (sy_call_t *)linux_rt_sigtimedwait, AUE_NULL, NULL, 0, 0 }, /* 177 = linux_rt_sigtimedwait */ + { AS(linux_rt_sigtimedwait_args), (sy_call_t *)linux_rt_sigtimedwait, AUE_NULL, NULL, 0, 0 }, /* 177 = linux_rt_sigtimedwait */ { 0, (sy_call_t *)linux_rt_sigqueueinfo, AUE_NULL, NULL, 0, 0 }, /* 178 = linux_rt_sigqueueinfo */ { AS(linux_rt_sigsuspend_args), (sy_call_t *)linux_rt_sigsuspend, AUE_NULL, NULL, 0, 0 }, /* 179 = linux_rt_sigsuspend */ { AS(linux_pread_args), (sy_call_t *)linux_pread, AUE_PREAD, NULL, 0, 0 }, /* 180 = linux_pread */ ==== //depot/projects/linuxolator/src/sys/amd64/linux32/syscalls.master#10 (text+ko) ==== @@ -310,7 +310,10 @@ l_size_t sigsetsize); } 176 AUE_NULL STD { int linux_rt_sigpending(l_sigset_t *set, \ l_size_t sigsetsize); } -177 AUE_NULL STD { int linux_rt_sigtimedwait(void); } +177 AUE_NULL STD { int linux_rt_sigtimedwait(l_sigset_t *mask, \ + l_siginfo_t *ptr, \ + struct l_timeval *timeout, \ + l_size_t sigsetsize); } 178 AUE_NULL STD { int linux_rt_sigqueueinfo(void); } 179 AUE_NULL STD { int linux_rt_sigsuspend( \ l_sigset_t *newset, \ ==== //depot/projects/linuxolator/src/sys/compat/linux/linux_signal.c#4 (text+ko) ==== @@ -422,6 +422,95 @@ return (copyout(&lset, args->set, args->sigsetsize)); } +/* + * MPSAFE + */ +int +linux_rt_sigtimedwait(struct thread *td, + struct linux_rt_sigtimedwait_args *args) +{ +#ifdef DEBUG + struct proc *p = td->td_proc; +#endif + int error; + l_timeval ltv; + struct timeval tv; + struct timespec ts, *tsa; + l_sigset_t lset; + sigset_t bset; + l_siginfo_t linfo; + ksiginfo_t info; + +#ifdef DEBUG + if (ldebug(rt_sigtimedwait)) + printf(ARGS(rt_sigtimedwait, "*")); +#endif + if (args->sigsetsize != sizeof(l_sigset_t)) + return(EINVAL); + + if ((error = copyin(args->mask, &lset, sizeof(lset)))) + return(error); + linux_to_bsd_sigset(&lset, &bset); + + tsa = NULL; + if (args->timeout) { + if ((error = copyin(args->timeout, <v, sizeof(ltv)))) + return(error); +#ifdef DEBUG + if (ldebug(rt_sigtimedwait)) + printf("Linux-emul rt_sigtimedwait (%ld): incoming timeout (%ld/%ld)\n", + (long)p->p_pid, ltv.tv_sec, ltv.tv_usec); +#endif + tv.tv_sec = (long)ltv.tv_sec; + tv.tv_usec = (suseconds_t)ltv.tv_usec; + if (itimerfix(&tv)) { + /* The timeout was invalid. Convert it to something + * valid that will act as it does under Linux. + */ + tv.tv_sec += tv.tv_usec / 1000000; + tv.tv_usec %= 1000000; + if (tv.tv_usec < 0) { + tv.tv_sec -= 1; + tv.tv_usec += 1000000; + } + if (tv.tv_sec < 0) + timevalclear(&tv); +#ifdef DEBUG + if (ldebug(rt_sigtimedwait)) + printf("Linux-emul rt_sigtimedwait (%ld): converted timeout (%ld/%ld)\n", + (long)p->p_pid, tv.tv_sec, tv.tv_usec); +#endif + } + TIMEVAL_TO_TIMESPEC(&tv, &ts); + tsa = &ts; + } + error = kern_sigtimedwait(td, bset, &info, tsa); +#ifdef DEBUG + if (ldebug(rt_sigtimedwait)) + printf("Linux-emul rt_sigtimedwait (%ld): sigtimedwait returning (%d)\n", + (long)p->p_pid, error); +#endif + if (error) + return error; + + if (args->ptr) { + memset(&linfo, 0, sizeof(linfo)); + linfo.lsi_signo = info.ksi_signo; + error = copyout(&linfo, args->ptr, sizeof(linfo)); + } + + /* Repost if we got an error. */ + if (error && info.ksi_signo) { + PROC_LOCK(td->td_proc); + tdsignal(td->td_proc, td, info.ksi_signo, &info); + PROC_UNLOCK(td->td_proc); + } else { + td->td_retval[0] = info.ksi_signo; + } + + return error; +} + int linux_kill(struct thread *td, struct linux_kill_args *args) { ==== //depot/projects/linuxolator/src/sys/i386/linux/linux_dummy.c#4 (text+ko) ==== @@ -56,7 +56,6 @@ DUMMY(vm86); DUMMY(query_module); DUMMY(nfsservctl); -DUMMY(rt_sigtimedwait); DUMMY(rt_sigqueueinfo); DUMMY(capget); DUMMY(capset); ==== //depot/projects/linuxolator/src/sys/i386/linux/linux_proto.h#9 (text+ko) ==== @@ -2,7 +2,7 @@ * System call prototypes. * * DO NOT EDIT-- this file is automatically generated. - * $FreeBSD: src/sys/i386/linux/linux_proto.h,v 1.85 2006/10/28 11:24:38 netchild Exp $ + * $FreeBSD$ * created from FreeBSD: src/sys/i386/linux/syscalls.master,v 1.82 2006/10/28 10:59:59 netchild Exp */ @@ -538,7 +538,10 @@ char sigsetsize_l_[PADL_(l_size_t)]; l_size_t sigsetsize; char sigsetsize_r_[PADR_(l_size_t)]; }; struct linux_rt_sigtimedwait_args { - register_t dummy; + char mask_l_[PADL_(l_sigset_t *)]; l_sigset_t * mask; char mask_r_[PADR_(l_sigset_t *)]; + char ptr_l_[PADL_(l_siginfo_t *)]; l_siginfo_t * ptr; char ptr_r_[PADR_(l_siginfo_t *)]; + char timeout_l_[PADL_(struct l_timeval *)]; struct l_timeval * timeout; char timeout_r_[PADR_(struct l_timeval *)]; + char sigsetsize_l_[PADL_(l_size_t)]; l_size_t sigsetsize; char sigsetsize_r_[PADR_(l_size_t)]; }; struct linux_rt_sigqueueinfo_args { register_t dummy; ==== //depot/projects/linuxolator/src/sys/i386/linux/linux_syscall.h#9 (text+ko) ==== @@ -2,7 +2,7 @@ * System call numbers. * * DO NOT EDIT-- this file is automatically generated. - * $FreeBSD: src/sys/i386/linux/linux_syscall.h,v 1.79 2006/10/28 11:24:38 netchild Exp $ + * $FreeBSD$ * created from FreeBSD: src/sys/i386/linux/syscalls.master,v 1.82 2006/10/28 10:59:59 netchild Exp */ ==== //depot/projects/linuxolator/src/sys/i386/linux/linux_sysent.c#9 (text+ko) ==== @@ -2,8 +2,8 @@ * System call switch table. * * DO NOT EDIT-- this file is automatically generated. - * $FreeBSD: src/sys/i386/linux/linux_sysent.c,v 1.87 2006/10/29 14:12:44 netchild Exp $ - * created from FreeBSD: src/sys/i386/linux/syscalls.master,v 1.83 2006/10/29 14:02:39 netchild Exp + * $FreeBSD$ + * created from FreeBSD: src/sys/i386/linux/syscalls.master,v 1.82 2006/10/28 10:59:59 netchild Exp */ #include @@ -196,7 +196,7 @@ { AS(linux_rt_sigaction_args), (sy_call_t *)linux_rt_sigaction, AUE_NULL, NULL, 0, 0 }, /* 174 = linux_rt_sigaction */ { AS(linux_rt_sigprocmask_args), (sy_call_t *)linux_rt_sigprocmask, AUE_NULL, NULL, 0, 0 }, /* 175 = linux_rt_sigprocmask */ { AS(linux_rt_sigpending_args), (sy_call_t *)linux_rt_sigpending, AUE_NULL, NULL, 0, 0 }, /* 176 = linux_rt_sigpending */ - { 0, (sy_call_t *)linux_rt_sigtimedwait, AUE_NULL, NULL, 0, 0 }, /* 177 = linux_rt_sigtimedwait */ + { AS(linux_rt_sigtimedwait_args), (sy_call_t *)linux_rt_sigtimedwait, AUE_NULL, NULL, 0, 0 }, /* 177 = linux_rt_sigtimedwait */ { 0, (sy_call_t *)linux_rt_sigqueueinfo, AUE_NULL, NULL, 0, 0 }, /* 178 = linux_rt_sigqueueinfo */ { AS(linux_rt_sigsuspend_args), (sy_call_t *)linux_rt_sigsuspend, AUE_NULL, NULL, 0, 0 }, /* 179 = linux_rt_sigsuspend */ { AS(linux_pread_args), (sy_call_t *)linux_pread, AUE_PREAD, NULL, 0, 0 }, /* 180 = linux_pread */ @@ -264,11 +264,11 @@ { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0 }, /* 242 = linux_sched_getaffinity */ { AS(linux_set_thread_area_args), (sy_call_t *)linux_set_thread_area, AUE_NULL, NULL, 0, 0 }, /* 243 = linux_set_thread_area */ { AS(linux_get_thread_area_args), (sy_call_t *)linux_get_thread_area, AUE_NULL, NULL, 0, 0 }, /* 244 = linux_get_thread_area */ - { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0 }, /* 245 = linux_io_setup */ - { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0 }, /* 246 = linux_io_destroy */ - { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0 }, /* 247 = linux_io_getevents */ - { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0 }, /* 248 = linux_io_submit */ - { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0 }, /* 249 = linux_io_cancel */ + { AS(linux_io_setup_args), (sy_call_t *)linux_io_setup, AUE_NULL, NULL, 0, 0 }, /* 245 = linux_io_setup */ + { AS(linux_io_destroy_args), (sy_call_t *)linux_io_destroy, AUE_NULL, NULL, 0, 0 }, /* 246 = linux_io_destroy */ + { AS(linux_io_getevents_args), (sy_call_t *)linux_io_getevents, AUE_NULL, NULL, 0, 0 }, /* 247 = linux_io_getevents */ + { AS(linux_io_submit_args), (sy_call_t *)linux_io_submit, AUE_NULL, NULL, 0, 0 }, /* 248 = linux_io_submit */ + { AS(linux_io_cancel_args), (sy_call_t *)linux_io_cancel, AUE_NULL, NULL, 0, 0 }, /* 249 = linux_io_cancel */ { 0, (sy_call_t *)linux_fadvise64, AUE_NULL, NULL, 0, 0 }, /* 250 = linux_fadvise64 */ { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0 }, /* 251 = */ { AS(linux_exit_group_args), (sy_call_t *)linux_exit_group, AUE_EXIT, NULL, 0, 0 }, /* 252 = linux_exit_group */ ==== //depot/projects/linuxolator/src/sys/i386/linux/syscalls.master#8 (text+ko) ==== @@ -313,7 +313,10 @@ l_size_t sigsetsize); } 176 AUE_NULL STD { int linux_rt_sigpending(l_sigset_t *set, \ l_size_t sigsetsize); } -177 AUE_NULL STD { int linux_rt_sigtimedwait(void); } +177 AUE_NULL STD { int linux_rt_sigtimedwait(l_sigset_t *mask, \ + l_siginfo_t *ptr, \ + struct l_timeval *timeout, \ + l_size_t sigsetsize); } 178 AUE_NULL STD { int linux_rt_sigqueueinfo(void); } 179 AUE_NULL STD { int linux_rt_sigsuspend( \ l_sigset_t *newset, \