Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 29 Oct 2006 17:29:34 GMT
From:      Alexander Leidinger <netchild@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 108671 for review
Message-ID:  <200610291729.k9THTYvY070930@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
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 <hostmaster@whois.gts.net>

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, &ltv, 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 <bsm/audit_kevents.h>
@@ -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, \



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200610291729.k9THTYvY070930>