From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on starla X-Spam-Level: X-Spam-Status: No, score=-0.9 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 41E561F44D for ; Sat, 23 Mar 2024 17:35:35 +0000 (UTC) Authentication-Results: dcvr.yhbt.net; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=Un8cNQ0E; dkim-atps=neutral Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 62193385828B for ; Sat, 23 Mar 2024 17:35:32 +0000 (GMT) Received: from mail-lf1-x135.google.com (mail-lf1-x135.google.com [IPv6:2a00:1450:4864:20::135]) by sourceware.org (Postfix) with ESMTPS id 01A613858D28 for ; Sat, 23 Mar 2024 17:35:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 01A613858D28 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 01A613858D28 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::135 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711215309; cv=none; b=RKMILHWtvyGUK2W3EweJGnZwSswl9uoeA1D3qs0BTB9+bTEfcQXuKhHNbeA/MbUSstcCZrMGZA6aNF6vbTglKfYS2WEkpg5wbonLMZch2qc9lmH3k7g5hS2S8v/OURBwC7DF9YtKmoLa5BVac3SMqNq18HUR/IW9X+iIhd7xu5E= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711215309; c=relaxed/simple; bh=KNLGR0eiUWbqXrqukeGy3hAegNIod3CymT93i1hSpqo=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=Pq+XLye/rmGyNEUCqINDk4sWuXIpsP4PYHfCrE1JrPQge8keDEERmwyrhEeYCaYv5ag/XXkKLPfKDhjZ/Mlz1kwvCNoJsE1RI31F+hae2oz1RGWsJcAGcPDy5EuWDK1w0NNiI4JFyakjcmDGow835tOo+FdFY0JvGqjxI0CLHBY= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lf1-x135.google.com with SMTP id 2adb3069b0e04-5148ea935b8so3606411e87.1 for ; Sat, 23 Mar 2024 10:35:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711215305; x=1711820105; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=t1Iaii2YTOAQl6WcpzdKbl17JYVWmkT8kTWGwJlcu/s=; b=Un8cNQ0EedEqAJsLCiGRmud06vAr1SYRC9gB8sjaOHOFvRSOQKru01+Pjz9o21bgTC waHlDASPu4BPbPzG9QQwDRFD/SjUviehu6h+oijKqPNyrMYk3FOS1fMuCjwnxYI67oN/ OHNFzbhiVB5dxV8iheE0M6T25ED5LCfPYE4mqkYbmgjzjdcptK/iGiBGl3wK884vZCem rX2kG0etxGhlN5PZSeJO67yyCFw1YsC1DBVj9JvxF+X5Wk/5tgckGinVuqcAX1z/FBb7 3RgK7g6vXwwbp7j/CPwe+8/rXMlHCuXqJFPeef20MOfhlMKVwqMOS22Bg6/xlpakABYs B2vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711215305; x=1711820105; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=t1Iaii2YTOAQl6WcpzdKbl17JYVWmkT8kTWGwJlcu/s=; b=IvduP1xpdP/awExTFkQpxnTIwNoUQ1vvokiVVOmCQNWWa9h15mrsEuCSNdZd7B3peB qoPIEn1BEE9Vq4YsurijHhrgyiF5Gmq8rB66LAqDHO5aCyxbUHQcqlwzxpI1fZTuGWhK wQO+OlGEdz+6Y7Kk49E4/IFdb4PaDZYSHiyy5m/9pIBqHYD5kqZ5mwanAK1ONg9BWd5c 1OyxspYsF4zGJdTcyucdIvLmEgOWxxFQHqRugD+HBZ6N1x+Ve699RuGuN4BCgTnXdW2o CvAIBV5Id5fpISHpakvQax3hJelFULo4zNJlQ7ZipcqmFbPyWcyvnVKcvpS+nUdGBpBt 3jlw== X-Gm-Message-State: AOJu0YynmxV/UtECEJO2Y96tW/XyPrYv+sEgNruRXjdbMIz3pQK6AqC1 o/b40lksPqNitWMZa/oGFYy90FNV0WweLiBJidTWbmG5cXtOJT+pD8YlXKkA X-Google-Smtp-Source: AGHT+IFe14bjcIHibXuwb9Ws1pi7+ZyCdg/d7ENwCgKoXXBv/8SRlunzHXZiD9gnl660/NFy9QYnNw== X-Received: by 2002:ac2:5fed:0:b0:513:d4be:7e40 with SMTP id s13-20020ac25fed000000b00513d4be7e40mr1744108lfg.23.1711215304706; Sat, 23 Mar 2024 10:35:04 -0700 (PDT) Received: from surface-pro-6.. (79-139-171-253.dynamic.spd-mgts.ru. [79.139.171.253]) by smtp.gmail.com with ESMTPSA id g20-20020ac25394000000b00513973dee6fsm361290lfh.150.2024.03.23.10.35.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Mar 2024 10:35:04 -0700 (PDT) From: Sergey Bugaev To: libc-alpha@sourceware.org, bug-hurd@gnu.org Cc: Maxim Kuvyrkov , Luca Subject: [PATCH v2 01/20] hurd: Move internal functions to internal header Date: Sat, 23 Mar 2024 20:32:42 +0300 Message-ID: <20240323173301.151066-2-bugaevc@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240323173301.151066-1-bugaevc@gmail.com> References: <20240323173301.151066-1-bugaevc@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+e=80x24.org@sourceware.org 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 to the includes, and use __LIBC_NO_TLS () unconditionally. Signed-off-by: Sergey Bugaev --- 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 /* For `jmp_buf'. */ #include struct hurd_signal_preemptor; /* */ -#if defined __USE_EXTERN_INLINES && defined _LIBC -# if IS_IN (libc) || IS_IN (libpthread) -# include -# 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 #ifndef _ISOMAC + +#if defined __USE_EXTERN_INLINES +# if IS_IN (libc) || IS_IN (libpthread) +# include +# include +# 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