diff options
Diffstat (limited to 'hurd/hurd/signal.h')
-rw-r--r-- | hurd/hurd/signal.h | 58 |
1 files changed, 33 insertions, 25 deletions
diff --git a/hurd/hurd/signal.h b/hurd/hurd/signal.h index fa5c6e9ebb..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,12 +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> 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. */ @@ -73,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 @@ -84,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. */ @@ -154,15 +159,16 @@ extern void _hurd_sigstate_delete (thread_t thread); #define _HURD_SIGNAL_H_EXTERN_INLINE __extern_inline #endif -#if defined __USE_EXTERN_INLINES && defined _LIBC && !defined NOT_IN_libc +#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 = &THREAD_SELF->_hurd_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,30 +190,29 @@ extern int _hurd_core_limit; interrupted lest the signal handler try to take the same lock and deadlock result. */ -void *_hurd_critical_section_lock (void); +extern void *_hurd_critical_section_lock (void); -#if defined __USE_EXTERN_INLINES && defined _LIBC && !defined NOT_IN_libc +#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 *ss; #ifdef __LIBC_NO_TLS - if (__LIBC_NO_TLS()) + if (__LIBC_NO_TLS ()) /* TLS is currently initializing, no need to enter critical section. */ return NULL; #endif - location = &THREAD_SELF->_hurd_sigstate; - ss = *location; + 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)) @@ -219,11 +224,13 @@ _hurd_critical_section_lock (void) _hurd_critical_section_unlock to unlock it. */ return ss; } +# endif #endif -void _hurd_critical_section_unlock (void *our_lock); +extern void _hurd_critical_section_unlock (void *our_lock); -#if defined __USE_EXTERN_INLINES && defined _LIBC && !defined NOT_IN_libc +#if defined __USE_EXTERN_INLINES && defined _LIBC +# if IS_IN (libc) _HURD_SIGNAL_H_EXTERN_INLINE void _hurd_critical_section_unlock (void *our_lock) { @@ -246,6 +253,7 @@ _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. @@ -376,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); \ |