mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-21 12:30:06 +00:00
hurd: Move internal functions to internal header
Move _hurd_self_sigstate (), _hurd_critical_section_lock (), and _hurd_critical_section_unlock () inline implementations (that were already guarded by #if defined _LIBC) to the internal version of the header. While at it, add <tls.h> to the includes, and use __LIBC_NO_TLS () unconditionally. Signed-off-by: Sergey Bugaev <bugaevc@gmail.com> Message-ID: <20240323173301.151066-2-bugaevc@gmail.com>
This commit is contained in:
parent
4a13b3ef46
commit
7f02511e5b
@ -40,11 +40,6 @@
|
|||||||
#include <setjmp.h> /* For `jmp_buf'. */
|
#include <setjmp.h> /* For `jmp_buf'. */
|
||||||
#include <spin-lock.h>
|
#include <spin-lock.h>
|
||||||
struct hurd_signal_preemptor; /* <hurd/sigpreempt.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. */
|
/* Full details of a signal. */
|
||||||
@ -157,33 +152,6 @@ extern void _hurd_sigstate_unlock (struct hurd_sigstate *ss);
|
|||||||
/* Used by libpthread to remove stale sigstate structures. */
|
/* Used by libpthread to remove stale sigstate structures. */
|
||||||
extern void _hurd_sigstate_delete (thread_t thread);
|
extern void _hurd_sigstate_delete (thread_t thread);
|
||||||
|
|
||||||
#ifndef _HURD_SIGNAL_H_EXTERN_INLINE
|
|
||||||
#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 *ss = THREAD_GETMEM (THREAD_SELF, _hurd_sigstate);
|
|
||||||
if (__glibc_unlikely (ss == NULL))
|
|
||||||
{
|
|
||||||
thread_t self = __mach_thread_self ();
|
|
||||||
|
|
||||||
/* 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 = _hurd_thread_sigstate (self);
|
|
||||||
THREAD_SETMEM (THREAD_SELF, _hurd_sigstate, ss);
|
|
||||||
__mach_port_deallocate (__mach_task_self (), self);
|
|
||||||
}
|
|
||||||
return ss;
|
|
||||||
}
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct machine_thread_all_state;
|
struct machine_thread_all_state;
|
||||||
extern mach_port_t
|
extern mach_port_t
|
||||||
_hurdsig_abort_rpcs (struct hurd_sigstate *ss, int signo, int sigthread,
|
_hurdsig_abort_rpcs (struct hurd_sigstate *ss, int signo, int sigthread,
|
||||||
@ -215,63 +183,8 @@ extern int _hurd_core_limit;
|
|||||||
avoid unexpectingly exposing EINTR to the application. */
|
avoid unexpectingly exposing EINTR to the application. */
|
||||||
|
|
||||||
extern void *_hurd_critical_section_lock (void);
|
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 *ss;
|
|
||||||
|
|
||||||
#ifdef __LIBC_NO_TLS
|
|
||||||
if (__LIBC_NO_TLS ())
|
|
||||||
/* TLS is currently initializing, no need to enter critical section. */
|
|
||||||
return NULL;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ss = _hurd_self_sigstate ();
|
|
||||||
|
|
||||||
if (! __spin_try_lock (&ss->critical_section_lock))
|
|
||||||
/* We are already in a critical section, so do nothing. */
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
/* With the critical section lock held no signal handler will run.
|
|
||||||
Return our sigstate pointer; this will be passed to
|
|
||||||
_hurd_critical_section_unlock to unlock it. */
|
|
||||||
return ss;
|
|
||||||
}
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
extern void _hurd_critical_section_unlock (void *our_lock);
|
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)
|
|
||||||
{
|
|
||||||
if (our_lock == NULL)
|
|
||||||
/* The critical section lock was held when we began. Do nothing. */
|
|
||||||
return;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* It was us who acquired the critical section lock. Unlock it. */
|
|
||||||
struct hurd_sigstate *ss = (struct hurd_sigstate *) our_lock;
|
|
||||||
sigset_t pending;
|
|
||||||
_hurd_sigstate_lock (ss);
|
|
||||||
__spin_unlock (&ss->critical_section_lock);
|
|
||||||
pending = _hurd_sigstate_pending (ss) & ~ss->blocked;
|
|
||||||
_hurd_sigstate_unlock (ss);
|
|
||||||
if (__glibc_unlikely (!__sigisemptyset (&pending)))
|
|
||||||
/* There are unblocked signals pending, which weren't
|
|
||||||
delivered because we were in the critical section.
|
|
||||||
Tell the signal thread to deliver them now. */
|
|
||||||
__msg_sig_post (_hurd_msgport, 0, 0, __mach_task_self ());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Convenient macros for simple uses of critical sections.
|
/* Convenient macros for simple uses of critical sections.
|
||||||
These two must be used as a pair at the same C scoping level. */
|
These two must be used as a pair at the same C scoping level. */
|
||||||
|
|
||||||
|
@ -9,6 +9,84 @@ libc_hidden_proto (_hurd_self_sigstate)
|
|||||||
#include_next <hurd/signal.h>
|
#include_next <hurd/signal.h>
|
||||||
|
|
||||||
#ifndef _ISOMAC
|
#ifndef _ISOMAC
|
||||||
|
|
||||||
|
#if defined __USE_EXTERN_INLINES
|
||||||
|
# if IS_IN (libc) || IS_IN (libpthread)
|
||||||
|
# include <sigsetops.h>
|
||||||
|
# include <tls.h>
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef _HURD_SIGNAL_H_EXTERN_INLINE
|
||||||
|
#define _HURD_SIGNAL_H_EXTERN_INLINE __extern_inline
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined __USE_EXTERN_INLINES && IS_IN (libc)
|
||||||
|
_HURD_SIGNAL_H_EXTERN_INLINE struct hurd_sigstate *
|
||||||
|
_hurd_self_sigstate (void)
|
||||||
|
{
|
||||||
|
struct hurd_sigstate *ss = THREAD_GETMEM (THREAD_SELF, _hurd_sigstate);
|
||||||
|
if (__glibc_unlikely (ss == NULL))
|
||||||
|
{
|
||||||
|
thread_t self = __mach_thread_self ();
|
||||||
|
|
||||||
|
/* 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 = _hurd_thread_sigstate (self);
|
||||||
|
THREAD_SETMEM (THREAD_SELF, _hurd_sigstate, ss);
|
||||||
|
__mach_port_deallocate (__mach_task_self (), self);
|
||||||
|
}
|
||||||
|
return ss;
|
||||||
|
}
|
||||||
|
|
||||||
|
_HURD_SIGNAL_H_EXTERN_INLINE void *
|
||||||
|
_hurd_critical_section_lock (void)
|
||||||
|
{
|
||||||
|
struct hurd_sigstate *ss;
|
||||||
|
|
||||||
|
if (__LIBC_NO_TLS ())
|
||||||
|
/* TLS is currently initializing, no need to enter critical section. */
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
ss = _hurd_self_sigstate ();
|
||||||
|
|
||||||
|
if (! __spin_try_lock (&ss->critical_section_lock))
|
||||||
|
/* We are already in a critical section, so do nothing. */
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
/* With the critical section lock held no signal handler will run.
|
||||||
|
Return our sigstate pointer; this will be passed to
|
||||||
|
_hurd_critical_section_unlock to unlock it. */
|
||||||
|
return ss;
|
||||||
|
}
|
||||||
|
|
||||||
|
_HURD_SIGNAL_H_EXTERN_INLINE void
|
||||||
|
_hurd_critical_section_unlock (void *our_lock)
|
||||||
|
{
|
||||||
|
if (our_lock == NULL)
|
||||||
|
/* The critical section lock was held when we began. Do nothing. */
|
||||||
|
return;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* It was us who acquired the critical section lock. Unlock it. */
|
||||||
|
struct hurd_sigstate *ss = (struct hurd_sigstate *) our_lock;
|
||||||
|
sigset_t pending;
|
||||||
|
_hurd_sigstate_lock (ss);
|
||||||
|
__spin_unlock (&ss->critical_section_lock);
|
||||||
|
pending = _hurd_sigstate_pending (ss) & ~ss->blocked;
|
||||||
|
_hurd_sigstate_unlock (ss);
|
||||||
|
if (__glibc_unlikely (!__sigisemptyset (&pending)))
|
||||||
|
/* There are unblocked signals pending, which weren't
|
||||||
|
delivered because we were in the critical section.
|
||||||
|
Tell the signal thread to deliver them now. */
|
||||||
|
__msg_sig_post (_hurd_msgport, 0, 0, __mach_task_self ());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif /* defined __USE_EXTERN_INLINES && IS_IN (libc) */
|
||||||
|
|
||||||
|
|
||||||
libc_hidden_proto (_hurd_exception2signal)
|
libc_hidden_proto (_hurd_exception2signal)
|
||||||
libc_hidden_proto (_hurd_intr_rpc_mach_msg)
|
libc_hidden_proto (_hurd_intr_rpc_mach_msg)
|
||||||
libc_hidden_proto (_hurd_thread_sigstate)
|
libc_hidden_proto (_hurd_thread_sigstate)
|
||||||
|
Loading…
Reference in New Issue
Block a user