unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Sergey Bugaev <bugaevc@gmail.com>
To: libc-alpha@sourceware.org, bug-hurd@gnu.org
Cc: Maxim Kuvyrkov <maxim.kuvyrkov@linaro.org>, Luca <luca@orpolo.org>
Subject: [PATCH v2 01/20] hurd: Move internal functions to internal header
Date: Sat, 23 Mar 2024 20:32:42 +0300	[thread overview]
Message-ID: <20240323173301.151066-2-bugaevc@gmail.com> (raw)
In-Reply-To: <20240323173301.151066-1-bugaevc@gmail.com>

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>
---

This is the remaining part of the "hurd: Add some missing includes"
patch from v1, redone in a different way, as discussed last time.

The hurd/check-installed-headers-c test seems to pass for me, but please
check on your end too.

 hurd/hurd/signal.h                 | 87 ------------------------------
 sysdeps/hurd/include/hurd/signal.h | 78 +++++++++++++++++++++++++++
 2 files changed, 78 insertions(+), 87 deletions(-)

diff --git a/hurd/hurd/signal.h b/hurd/hurd/signal.h
index 6bc7103b..5d116fb2 100644
--- a/hurd/hurd/signal.h
+++ b/hurd/hurd/signal.h
@@ -40,11 +40,6 @@
 #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.  */
@@ -157,33 +152,6 @@ extern void _hurd_sigstate_unlock (struct hurd_sigstate *ss);
 /* Used by libpthread to remove stale sigstate structures.  */
 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;
 extern mach_port_t
 _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.  */
 
 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);
 
-#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.
    These two must be used as a pair at the same C scoping level.  */
 
diff --git a/sysdeps/hurd/include/hurd/signal.h b/sysdeps/hurd/include/hurd/signal.h
index 1dc8a1f3..fab8d1b6 100644
--- a/sysdeps/hurd/include/hurd/signal.h
+++ b/sysdeps/hurd/include/hurd/signal.h
@@ -9,6 +9,84 @@ libc_hidden_proto (_hurd_self_sigstate)
 #include_next <hurd/signal.h>
 
 #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_intr_rpc_mach_msg)
 libc_hidden_proto (_hurd_thread_sigstate)
-- 
2.44.0


  reply	other threads:[~2024-03-23 17:35 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-23 17:32 [PATCH v2 00/20] aarch64-gnu port & GNU/Hurd on AArch64 progress Sergey Bugaev
2024-03-23 17:32 ` Sergey Bugaev [this message]
2024-03-23 17:32 ` [PATCH v2 02/20] hurd: Stop relying on VM_MAX_ADDRESS Sergey Bugaev
2024-03-23 17:32 ` [PATCH v2 03/20] Allow glibc to be compiled without EXEC_PAGESIZE Sergey Bugaev
2024-03-23 17:32 ` [PATCH v2 04/20] hurd: Disable Prefer_MAP_32BIT_EXEC on non-x86_64 for now Sergey Bugaev
2024-03-23 17:32 ` [PATCH v2 05/20] hurd: Use the RETURN_ADDRESS macro Sergey Bugaev
2024-03-23 17:32 ` [PATCH v2 06/20] htl: Respect GL(dl_stack_flags) when allocating stacks Sergey Bugaev
2024-03-23 17:32 ` [PATCH v2 07/20] aarch64: Move pointer_guard.h out of sysdeps/unix/sysv/linux Sergey Bugaev
2024-03-23 17:32 ` [PATCH v2 08/20] aarch64: Add dl-procinfo Sergey Bugaev
2024-03-23 17:32 ` [PATCH v2 09/20] aarch64: Move saving user entry into _dl_start_user Sergey Bugaev
2024-03-23 17:32 ` [PATCH v2 10/20] aarch64: Allow building without kernel support for BTI Sergey Bugaev
2024-03-23 17:32 ` [PATCH v2 11/20] mach: Add a basic AArch64 port Sergey Bugaev
2024-03-23 17:32 ` [PATCH v2 12/20] mach: Declare the new thread_set_self_state () trap Sergey Bugaev
2024-03-23 17:32 ` [PATCH v2 13/20] hurd: Add a basic AArch64 port Sergey Bugaev
2024-03-23 17:32 ` [PATCH v2 14/20] hurd: Implement TLS on AArch64 Sergey Bugaev
2024-03-23 17:32 ` [PATCH v2 15/20] hurd: Implement longjmp for AArch64 Sergey Bugaev
2024-03-23 17:32 ` [PATCH v2 16/20] Add FPE_FLTIDO Sergey Bugaev
2024-03-23 17:32 ` [PATCH v2 17/20] hurd: Add an AArch64 signal implementation Sergey Bugaev
2024-03-23 17:32 ` [PATCH v2 18/20] htl: Implement some support for TLS_DTV_AT_TP Sergey Bugaev
2024-03-23 17:33 ` [PATCH v2 19/20] htl: Add an AArch64 implementation Sergey Bugaev
2024-03-23 17:33 ` [PATCH v2 20/20] hurd: Add expected aarch64-gnu abistlists Sergey Bugaev
2024-03-23 22:16 ` [PATCH v2 00/20] aarch64-gnu port & GNU/Hurd on AArch64 progress Samuel Thibault
2024-03-26  8:29 ` Sergey Bugaev
2024-03-26 10:15   ` Maxim Kuvyrkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/libc/involved.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240323173301.151066-2-bugaevc@gmail.com \
    --to=bugaevc@gmail.com \
    --cc=bug-hurd@gnu.org \
    --cc=libc-alpha@sourceware.org \
    --cc=luca@orpolo.org \
    --cc=maxim.kuvyrkov@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).