[Glibc-bsd-commits] r5130 - in trunk/glibc-ports/kfreebsd: . bits

Petr Salinger ps-guest at alioth.debian.org
Fri Nov 8 17:32:54 UTC 2013


Author: ps-guest
Date: 2013-11-08 17:32:53 +0000 (Fri, 08 Nov 2013)
New Revision: 5130

Modified:
   trunk/glibc-ports/kfreebsd/bits/waitstatus.h
   trunk/glibc-ports/kfreebsd/kernel-features.h
   trunk/glibc-ports/kfreebsd/syscalls.list
   trunk/glibc-ports/kfreebsd/waitid.c
Log:
use wait6() for waitid when available


Modified: trunk/glibc-ports/kfreebsd/bits/waitstatus.h
===================================================================
--- trunk/glibc-ports/kfreebsd/bits/waitstatus.h	2013-11-07 20:59:29 UTC (rev 5129)
+++ trunk/glibc-ports/kfreebsd/bits/waitstatus.h	2013-11-08 17:32:53 UTC (rev 5130)
@@ -34,29 +34,26 @@
 /* Nonzero if STATUS indicates normal termination.  */
 #define	__WIFEXITED(status)	(__WTERMSIG(status) == 0)
 
-/* Nonzero if STATUS indicates termination by a signal.  */
-#define __WIFSIGNALED(status) \
-  (((signed char) (((status) & 0x7f) + 1) >> 1) > 0)
-
 /* Nonzero if STATUS indicates the child is stopped.  */
 #define	__WIFSTOPPED(status)	(((status) & 0x7f) == 0x7f)
 
-/* Nonzero if STATUS indicates the child continued after a stop.  We only
-   define this if <bits/waitflags.h> provides the WCONTINUED flag bit.  */
-#ifdef WCONTINUED
-# define __WIFCONTINUED(status)	((status) == __W_CONTINUED)
-#endif
+/* Linux uses 0xffff, BSD uses SIGCONT */
+#define __W_CONTINUED		0x13
+#define	__WCOREFLAG		0x80
+/* Nonzero if STATUS indicates the child continued after a stop. */
+#define __WIFCONTINUED(status)	((status) == __W_CONTINUED)
 
 /* Nonzero if STATUS indicates the child dumped core.  */
 #define	__WCOREDUMP(status)	((status) & __WCOREFLAG)
 
+/* Nonzero if STATUS indicates termination by a signal.  */
+#define __WIFSIGNALED(status) \
+  (!__WIFSTOPPED(status) && !__WIFEXITED(status) && !__WIFCONTINUED(status))
+
 /* Macros for constructing status values.  */
 #define	__W_EXITCODE(ret, sig)	((ret) << 8 | (sig))
 #define	__W_STOPCODE(sig)	((sig) << 8 | 0x7f)
 
-/* Linux uses 0xffff, BSD uses SIGCONT */
-#define __W_CONTINUED		0x13
-#define	__WCOREFLAG		0x80
 
 
 #ifdef	__USE_BSD

Modified: trunk/glibc-ports/kfreebsd/kernel-features.h
===================================================================
--- trunk/glibc-ports/kfreebsd/kernel-features.h	2013-11-07 20:59:29 UTC (rev 5129)
+++ trunk/glibc-ports/kfreebsd/kernel-features.h	2013-11-08 17:32:53 UTC (rev 5130)
@@ -84,5 +84,10 @@
 # define __ASSUME_FALLOCATE		1
 #endif
 
+/* The wait6 syscall was introduced in kFreeBSD 9.2. */
+#if __KFREEBSD_KERNEL_VERSION >= 0x90200
+# define __ASSUME_WAIT6			1
+#endif
+
 /* Support for private "futexes" was added before we start with fbtl. */
 # define __ASSUME_PRIVATE_FUTEX		1

Modified: trunk/glibc-ports/kfreebsd/syscalls.list
===================================================================
--- trunk/glibc-ports/kfreebsd/syscalls.list	2013-11-07 20:59:29 UTC (rev 5129)
+++ trunk/glibc-ports/kfreebsd/syscalls.list	2013-11-08 17:32:53 UTC (rev 5130)
@@ -207,6 +207,7 @@
 unmount			-	unmount			i:si		unmount
 utrace			-	utrace			i:bn		utrace
 wait4			-	wait4			i:iWiP		__syscall_wait4 __wait4	wait4
+sys_wait6		EXTRA	wait6			i:iiWiPP	__syscall_wait6
 sys_write		-	write			i:ibn		__syscall_write
 sys_writev		-	writev			i:ipi		__syscall_writev
 yield			-	yield			i:		__syscall_yield

Modified: trunk/glibc-ports/kfreebsd/waitid.c
===================================================================
--- trunk/glibc-ports/kfreebsd/waitid.c	2013-11-07 20:59:29 UTC (rev 5129)
+++ trunk/glibc-ports/kfreebsd/waitid.c	2013-11-08 17:32:53 UTC (rev 5130)
@@ -22,9 +22,52 @@
 #include <sys/wait.h>
 #include <sysdep.h>
 
-/* for now only the wrapper implementation */
-/* later on we will try to use wait6 when available */
+extern int __syscall_wait6 (idtype_t itype, int64_t id,
+			    int *status, int options,
+			    struct rusage *rusage, siginfo_t *infop);
+libc_hidden_proto (__syscall_wait6)
 
+
+#define DO_WAITID simulated_waitid
+static int simulated_waitid (idtype_t idtype, id_t id, siginfo_t *infop, int options);
+
+
+#if !defined __ASSUME_WAIT6
+static int __have_wait6;
+#endif
+
+static inline int
+do_waitid (idtype_t idtype, id_t id, siginfo_t *infop, int options)
+{
+  int ret;
+  int status;
+#ifndef __ASSUME_WAIT6
+  if (__have_wait6 >= 0)
+#endif
+  {
+      ret = INLINE_SYSCALL (wait6, 6, idtype, id, &status, options, NULL, infop);
+      
+      if (ret == 0 && infop != NULL)
+      {
+          memset(infop, 0, sizeof(*infop));
+      }
+      if (ret >= 0)
+          return 0;
+#ifndef __ASSUME_WAIT6
+      if (errno == ENOSYS)
+      {
+          __have_wait6 = -1;
+      }
+      else
+#endif
+      {
+          return ret;
+      }
+   }
+   return simulated_waitid(idtype, id, infop, options);
+}
+
+ 
 #define waitid __unused_waitid_alias
 #include <sysdeps/posix/waitid.c>
 #undef waitid




More information about the Glibc-bsd-commits mailing list