diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2018-12-27 16:34:38 +0000 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2018-12-27 16:34:38 +0000 |
commit | 7576c27563a3e43c0a276bf222244bcaf220a6fa (patch) | |
tree | ad96fd1f1b9b57a50005db7803f6b79e748bb820 /hurd/hurd/signal.h | |
parent | ab5f5211585bf0f33bbfa2d4aaf17e4f0d1fa564 (diff) | |
parent | 064374be911f72dfaec8a75f06da1f9fc1827712 (diff) |
Merge branch 't/hurdsig-global-dispositions' into refs/top-bases/t/hurdsig-SA_SIGINFO
Diffstat (limited to 'hurd/hurd/signal.h')
-rw-r--r-- | hurd/hurd/signal.h | 66 |
1 files changed, 45 insertions, 21 deletions
diff --git a/hurd/hurd/signal.h b/hurd/hurd/signal.h index 14955c4242..335ead910e 100644 --- a/hurd/hurd/signal.h +++ b/hurd/hurd/signal.h @@ -1,5 +1,5 @@ /* Implementing POSIX.1 signals under the Hurd. - Copyright (C) 1993-2016 Free Software Foundation, Inc. + Copyright (C) 1993-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -20,10 +20,6 @@ #define _HURD_SIGNAL_H 1 #include <features.h> -/* Make sure <signal.h> is going to define NSIG. */ -#ifndef __USE_GNU -#error "Must have `_GNU_SOURCE' feature test macro to use this file" -#endif #define __need_size_t #define __need_NULL @@ -35,13 +31,21 @@ #include <hurd/hurd_types.h> #include <signal.h> #include <errno.h> +#include <bits/types/error_t.h> +#include <bits/types/stack_t.h> +#include <bits/types/sigset_t.h> +#include <bits/sigaction.h> #include <hurd/msg.h> #include <cthreads.h> /* For `struct mutex'. */ #include <setjmp.h> /* For `jmp_buf'. */ #include <spin-lock.h> -#include <hurd/threadvar.h> /* We cache sigstate in a threadvar. */ struct hurd_signal_preemptor; /* <hurd/sigpreempt.h> */ +#if defined __USE_EXTERN_INLINES && defined _LIBC +# if IS_IN (libc) || IS_IN (libpthread) +# include <sigsetops.h> +# endif +#endif /* Full details of a signal. */ @@ -74,9 +78,9 @@ struct hurd_sigstate semantics: if sa_handler is SIG_IGN instead of SIG_DFL, this thread will receive global signals and use the process-wide action vector instead of this one. */ - struct sigaction actions[NSIG]; + struct sigaction actions[_NSIG]; - struct sigaltstack sigaltstack; + stack_t sigaltstack; /* Chain of thread-local signal preemptors; see <hurd/sigpreempt.h>. Each element of this chain is in local stack storage, and the chain @@ -85,7 +89,7 @@ struct hurd_sigstate struct hurd_signal_preemptor *preemptors; /* For each signal that may be pending, the details to deliver it with. */ - struct hurd_signal_detail pending_data[NSIG]; + struct hurd_signal_detail pending_data[_NSIG]; /* If `suspended' is set when this thread gets a signal, the signal thread sends an empty message to it. */ @@ -155,15 +159,17 @@ extern void _hurd_sigstate_delete (thread_t thread); #define _HURD_SIGNAL_H_EXTERN_INLINE __extern_inline #endif +#if defined __USE_EXTERN_INLINES && defined _LIBC +# if IS_IN (libc) _HURD_SIGNAL_H_EXTERN_INLINE struct hurd_sigstate * _hurd_self_sigstate (void) { - struct hurd_sigstate **location = (struct hurd_sigstate **) - (void *) __hurd_threadvar_location (_HURD_THREADVAR_SIGSTATE); - if (*location == NULL) - *location = _hurd_thread_sigstate (__mach_thread_self ()); - return *location; + if (THREAD_SELF->_hurd_sigstate == NULL) + THREAD_SELF->_hurd_sigstate = _hurd_thread_sigstate (__mach_thread_self ()); + return THREAD_SELF->_hurd_sigstate; } +# endif +#endif /* Thread listening on our message port; also called the "signal thread". */ @@ -184,19 +190,29 @@ extern int _hurd_core_limit; interrupted lest the signal handler try to take the same lock and deadlock result. */ +extern void *_hurd_critical_section_lock (void); + +#if defined __USE_EXTERN_INLINES && defined _LIBC +# if IS_IN (libc) _HURD_SIGNAL_H_EXTERN_INLINE void * _hurd_critical_section_lock (void) { - struct hurd_sigstate **location = (struct hurd_sigstate **) - (void *) __hurd_threadvar_location (_HURD_THREADVAR_SIGSTATE); - struct hurd_sigstate *ss = *location; + struct hurd_sigstate *ss; + +#ifdef __LIBC_NO_TLS + if (__LIBC_NO_TLS ()) + /* TLS is currently initializing, no need to enter critical section. */ + return NULL; +#endif + + ss = THREAD_SELF->_hurd_sigstate; if (ss == NULL) { /* The thread variable is unset; this must be the first time we've asked for it. In this case, the critical section flag cannot possible already be set. Look up our sigstate structure the slow way. */ - ss = *location = _hurd_thread_sigstate (__mach_thread_self ()); + ss = THREAD_SELF->_hurd_sigstate = _hurd_thread_sigstate (__mach_thread_self ()); } if (! __spin_try_lock (&ss->critical_section_lock)) @@ -208,7 +224,13 @@ _hurd_critical_section_lock (void) _hurd_critical_section_unlock to unlock it. */ return ss; } +# endif +#endif +extern void _hurd_critical_section_unlock (void *our_lock); + +#if defined __USE_EXTERN_INLINES && defined _LIBC +# if IS_IN (libc) _HURD_SIGNAL_H_EXTERN_INLINE void _hurd_critical_section_unlock (void *our_lock) { @@ -231,6 +253,8 @@ _hurd_critical_section_unlock (void *our_lock) __msg_sig_post (_hurd_msgport, 0, 0, __mach_task_self ()); } } +# endif +#endif /* Convenient macros for simple uses of critical sections. These two must be used as a pair at the same C scoping level. */ @@ -360,18 +384,18 @@ extern mach_msg_timeout_t _hurd_interrupted_rpc_timeout; do \ { \ /* Get the message port. */ \ - __err = (fetch_msgport_expr); \ + __err = (error_t) (fetch_msgport_expr); \ if (__err) \ break; \ /* Get the reference port. */ \ - __err = (fetch_refport_expr); \ + __err = (error_t) (fetch_refport_expr); \ if (__err) \ { \ /* Couldn't get it; deallocate MSGPORT and fail. */ \ __mach_port_deallocate (__mach_task_self (), msgport); \ break; \ } \ - __err = (rpc_expr); \ + __err = (error_t) (rpc_expr); \ __mach_port_deallocate (__mach_task_self (), msgport); \ if ((dealloc_refport) && refport != MACH_PORT_NULL) \ __mach_port_deallocate (__mach_task_self (), refport); \ |