summaryrefslogtreecommitdiff
path: root/hurd/hurd/signal.h
diff options
context:
space:
mode:
Diffstat (limited to 'hurd/hurd/signal.h')
-rw-r--r--hurd/hurd/signal.h66
1 files changed, 45 insertions, 21 deletions
diff --git a/hurd/hurd/signal.h b/hurd/hurd/signal.h
index 85e515293b..f84c4ef485 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. */
@@ -69,8 +73,8 @@ struct hurd_sigstate
sigset_t blocked; /* What signals are blocked. */
sigset_t pending; /* Pending signals, possibly blocked. */
- struct sigaction actions[NSIG];
- struct sigaltstack sigaltstack;
+ struct sigaction actions[_NSIG];
+ 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
@@ -79,7 +83,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. */
@@ -129,15 +133,17 @@ extern struct hurd_sigstate *_hurd_self_sigstate (void)
#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". */
@@ -164,19 +170,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))
@@ -188,7 +204,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)
{
@@ -211,6 +233,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. */
@@ -340,18 +364,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); \