Index: external/gpl3/gcc/dist/libstdc++-v3/include/std/mutex =================================================================== RCS file: /cvsroot/src/external/gpl3/gcc/dist/libstdc++-v3/include/std/mutex,v retrieving revision 1.3 diff -u -r1.3 mutex --- external/gpl3/gcc/dist/libstdc++-v3/include/std/mutex 24 Dec 2016 15:48:26 -0000 1.3 +++ external/gpl3/gcc/dist/libstdc++-v3/include/std/mutex 30 Dec 2016 03:30:46 -0000 @@ -695,7 +695,7 @@ call_once(once_flag& __once, _Callable&& __f, _Args&&... __args); }; -#ifdef _GLIBCXX_HAVE_TLS +#if defined(_GLIBCXX_HAVE_TLS) && defined(FIXME_PR_51139) extern __thread void* __once_callable; extern __thread void (*__once_call)(); @@ -722,7 +722,7 @@ void call_once(once_flag& __once, _Callable&& __f, _Args&&... __args) { -#ifdef _GLIBCXX_HAVE_TLS +#if defined(_GLIBCXX_HAVE_TLS) && defined(FIXME_PR_51139) auto __bound_functor = std::__bind_simple(std::forward<_Callable>(__f), std::forward<_Args>(__args)...); __once_callable = std::__addressof(__bound_functor); @@ -737,7 +737,7 @@ int __e = __gthread_once(&__once._M_once, &__once_proxy); -#ifndef _GLIBCXX_HAVE_TLS +#if !defined(_GLIBCXX_HAVE_TLS) || !defined(FIXME_PR_51139) if (__functor_lock) __set_once_functor_lock_ptr(0); #endif Index: external/gpl3/gcc/dist/libstdc++-v3/src/c++11/mutex.cc =================================================================== RCS file: /cvsroot/src/external/gpl3/gcc/dist/libstdc++-v3/src/c++11/mutex.cc,v retrieving revision 1.3 diff -u -r1.3 mutex.cc --- external/gpl3/gcc/dist/libstdc++-v3/src/c++11/mutex.cc 24 Dec 2016 15:48:26 -0000 1.3 +++ external/gpl3/gcc/dist/libstdc++-v3/src/c++11/mutex.cc 30 Dec 2016 03:30:46 -0000 @@ -25,7 +25,7 @@ #include #if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1) -#ifndef _GLIBCXX_HAVE_TLS +#if !defined(_GLIBCXX_HAVE_TLS) || !defined(FIXME_PR_51139) namespace { inline std::unique_lock*& @@ -41,7 +41,7 @@ { _GLIBCXX_BEGIN_NAMESPACE_VERSION -#ifdef _GLIBCXX_HAVE_TLS +#if defined(_GLIBCXX_HAVE_TLS) && defined(FIXME_PR_51139) __thread void* __once_callable; __thread void (*__once_call)(); #else @@ -76,7 +76,7 @@ { void __once_proxy() { -#ifndef _GLIBCXX_HAVE_TLS +#if !defined(_GLIBCXX_HAVE_TLS) || !defined(FIXME_PR_51139) function __once_call = std::move(__once_functor); if (unique_lock* __lock = __get_once_functor_lock_ptr()) { Index: sys/kern/kern_sig.c =================================================================== RCS file: /cvsroot/src/sys/kern/kern_sig.c,v retrieving revision 1.331 diff -u -r1.331 kern_sig.c --- sys/kern/kern_sig.c 4 Dec 2016 16:40:43 -0000 1.331 +++ sys/kern/kern_sig.c 30 Dec 2016 03:38:11 -0000 @@ -525,7 +525,7 @@ } static int -siggetinfo(sigpend_t *sp, ksiginfo_t *out, int signo) +siggetinfo(sigpend_t *sp, ksiginfo_t *out, int signo, bool keep) { ksiginfo_t *ksi, *nksi; @@ -538,8 +538,9 @@ if (ksi->ksi_signo != signo) continue; if (count++ > 0) /* Only remove the first, count all of them */ - continue; - TAILQ_REMOVE(&sp->sp_info, ksi, ksi_list); + continue; + if (!keep) + TAILQ_REMOVE(&sp->sp_info, ksi, ksi_list); KASSERT((ksi->ksi_flags & KSI_FROMPOOL) != 0); KASSERT((ksi->ksi_flags & KSI_QUEUED) != 0); ksi->ksi_flags &= ~KSI_QUEUED; @@ -563,6 +564,24 @@ } /* + * sigpeekinfo: + * + * Fetch the first pending signal from a set. Optionally, also fetch + * or manufacture a ksiginfo element. Returns the number of the first + * pending signal, or zero. + */ +void +sigpeekinfo(struct lwp *l, ksiginfo_t *ksi, int signo) +{ + struct proc *p = l->l_proc; + + KASSERT(mutex_owned(p->p_lock)); + + if (!siggetinfo(&l->l_sigpend, ksi, signo, false)) + (void)siggetinfo(&p->p_sigpend, ksi, signo, false); +} + +/* * sigget: * * Fetch the first pending signal from a set. Optionally, also fetch @@ -596,7 +615,7 @@ sigdelset(&sp->sp_set, signo); out: - count = siggetinfo(sp, out, signo); + count = siggetinfo(sp, out, signo, true); if (count > 1) sigaddset(&sp->sp_set, signo); return signo; @@ -1860,8 +1879,8 @@ l->l_ru.ru_nsignals++; if (l->l_sigpendset == NULL) { /* From the debugger */ - if (!siggetinfo(&l->l_sigpend, &ksi, signo)) - (void)siggetinfo(&p->p_sigpend, &ksi, signo); + if (!siggetinfo(&l->l_sigpend, &ksi, signo, true)) + (void)siggetinfo(&p->p_sigpend, &ksi, signo, true); } else sigget(l->l_sigpendset, &ksi, signo, NULL); Index: sys/kern/sys_ptrace_common.c =================================================================== RCS file: /cvsroot/src/sys/kern/sys_ptrace_common.c,v retrieving revision 1.7 diff -u -r1.7 sys_ptrace_common.c --- sys/kern/sys_ptrace_common.c 15 Dec 2016 12:04:18 -0000 1.7 +++ sys/kern/sys_ptrace_common.c 30 Dec 2016 03:38:12 -0000 @@ -210,6 +210,8 @@ case PT_SET_EVENT_MASK: case PT_GET_EVENT_MASK: case PT_GET_PROCESS_STATE: + case PT_SET_SIGINFO: + case PT_GET_SIGINFO: #ifdef __HAVE_PTRACE_MACHDEP PTRACE_MACHDEP_REQUEST_CASES #endif @@ -308,6 +310,7 @@ int signo = 0; int resume_all; ksiginfo_t ksi; + siginfo_t si; char *path; int len = 0; error = 0; @@ -448,6 +451,8 @@ case PT_SET_EVENT_MASK: case PT_GET_EVENT_MASK: case PT_GET_PROCESS_STATE: + case PT_SET_SIGINFO: + case PT_GET_SIGINFO: /* * You can't do what you want to the process if: * (1) It's not being traced at all, @@ -919,6 +924,63 @@ error = copyout(&pl, addr, sizeof(pl)); break; + case PT_SET_SIGINFO: + tmp = data; + if (tmp != 0 && t->p_nlwps > 1) { + lwp_delref(lt); + mutex_enter(t->p_lock); + lt = lwp_find(t, tmp); + if (lt == NULL) { + mutex_exit(t->p_lock); + error = ESRCH; + break; + } + lwp_addref(lt); + mutex_exit(t->p_lock); + } + + error = copyin(addr, &si, sizeof(si)); + if (error) + break; + + if (lt) { + lwp_addref(lt); + KSI_INIT_EMPTY(&ksi); + ksi.ksi_info = si._info; + /* ksi_lid 0 means to all */ + ksi.ksi_lid = tmp; + mutex_enter(t->p_lock); + error = kpsignal2(t, &ksi); + mutex_exit(t->p_lock); + } + break; + + case PT_GET_SIGINFO: + tmp = data; + if (tmp != 0 && t->p_nlwps > 1) { + lwp_delref(lt); + mutex_enter(t->p_lock); + lt = lwp_find(t, tmp); + if (lt == NULL) { + mutex_exit(t->p_lock); + error = ESRCH; + break; + } + lwp_addref(lt); + mutex_exit(t->p_lock); + } + + if (lt) { + mutex_enter(t->p_lock); + sigpeekinfo(lt, &ksi, t->p_sigctx.ps_signo); + error = copyout(addr, &ksi.ksi_info, sizeof(ksi.ksi_info)); + mutex_exit(t->p_lock); + } + + if (!error) + *retval = ksi.ksi_lid; + break; + #ifdef PT_SETREGS case PT_SETREGS: write = 1; Index: sys/sys/ptrace.h =================================================================== RCS file: /cvsroot/src/sys/sys/ptrace.h,v retrieving revision 1.51 diff -u -r1.51 ptrace.h --- sys/sys/ptrace.h 15 Dec 2016 20:04:36 -0000 1.51 +++ sys/sys/ptrace.h 30 Dec 2016 03:38:51 -0000 @@ -51,6 +51,8 @@ #define PT_SET_EVENT_MASK 16 /* set the event mask, defined below */ #define PT_GET_EVENT_MASK 17 /* get the event mask, defined below */ #define PT_GET_PROCESS_STATE 18 /* get process state, defined below */ +#define PT_SET_SIGINFO 19 /* set siginfo_t for signal */ +#define PT_GET_SIGINFO 20 /* get siginfo_t for signal */ #define PT_FIRSTMACH 32 /* for machine-specific requests */ #include /* machine-specific requests, if any */ @@ -74,7 +76,9 @@ /* 15 */ "PT_SYSCALLEMU", \ /* 16 */ "PT_SET_EVENT_MASK", \ /* 17 */ "PT_GET_EVENT_MASK", \ -/* 18 */ "PT_GET_PROCESS_STATE", +/* 18 */ "PT_GET_PROCESS_STATE", \ +/* 19 */ "PT_SET_SIGINFO", \ +/* 20 */ "PT_GET_SIGINFO", /* PT_{G,S}EVENT_MASK */ typedef struct ptrace_event { Index: sys/sys/signalvar.h =================================================================== RCS file: /cvsroot/src/sys/sys/signalvar.h,v retrieving revision 1.87 diff -u -r1.87 signalvar.h --- sys/sys/signalvar.h 4 Aug 2016 06:43:43 -0000 1.87 +++ sys/sys/signalvar.h 30 Dec 2016 03:38:51 -0000 @@ -153,6 +153,8 @@ int kpsignal2(struct proc *, ksiginfo_t *); +void sigpeekinfo(struct lwp *, ksiginfo_t *, int signo); + void signal_init(void); struct sigacts *sigactsinit(struct proc *, int);