From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id B5326388457F for ; Thu, 12 May 2022 19:44:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B5326388457F Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652384682; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references; bh=57tks+TrIEspODu6waATd0BmNX9EwC7np/Srq5BPwco=; b=SU2ocd/0ac7G0wqEoQPAQeEUIAOKg+ITSRELfYEcQR/VDgSQ5r2Ytq9m5jfq700ykx+E7G LgawRJKYoL90K1+8b5NCA0J7gqjZ1hAlIyJ+NYynvfmx642peJZ4X4+aRdwc4GBXqWp3AI Yh4Yc3byxfK2RcQYia/ugC7jRKoHbLM= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-97-OzTahxjKM42UZN4jxQI31A-1; Thu, 12 May 2022 15:44:41 -0400 X-MC-Unique: OzTahxjKM42UZN4jxQI31A-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C73B229DD9BC for ; Thu, 12 May 2022 19:44:40 +0000 (UTC) Received: from calimero.vinschen.de (unknown [10.36.112.8]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A335E2026D6A for ; Thu, 12 May 2022 19:44:40 +0000 (UTC) Received: by calimero.vinschen.de (Postfix, from userid 500) id 429C2A80884; Thu, 12 May 2022 21:44:39 +0200 (CEST) Date: Thu, 12 May 2022 21:44:39 +0200 From: Corinna Vinschen To: newlib@sourceware.org Subject: Re: [PATCH v2 00/11] Decouple global file object list from _GLOBAL_REENT Message-ID: Reply-To: newlib@sourceware.org Mail-Followup-To: newlib@sourceware.org References: <20220512121143.21473-1-matthew.joyce@embedded-brains.de> MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=vinschen@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: newlib@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Newlib mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 May 2022 19:44:44 -0000 On May 12 21:14, Corinna Vinschen wrote: > Hi Matt, > > On May 12 14:11, Matthew Joyce wrote: > > From: Matt Joyce > > > > Hello Corinna, > > > > Per your comments, please see version 2. > > > > 1) stdio_atexit is now called stdio_exit_handler > > 2) declarations for stdio_exit_handler() and _fwalk_sglue() are moved > > to sys/reent.h > > Please see my comments in terms of patch 11, which needs an additional > tweak. With this change, the patchset is GTG. Btw., it looks like Cygwin can switch to _REENT_GLOBAL_STDIO_STREAMS with only minor changes. I'll test this a bit more before pushing, but it's quite neat so far... diff --git a/winsup/cygwin/cygtls.cc b/winsup/cygwin/cygtls.cc index c8352adf9f25..0fd5509d2306 100644 --- a/winsup/cygwin/cygtls.cc +++ b/winsup/cygwin/cygtls.cc @@ -55,16 +55,8 @@ _cygtls::init_thread (void *x, DWORD (*func) (void *, void *)) _REENT_INIT_PTR (&local_clib); stackptr = stack; altstack.ss_flags = SS_DISABLE; - if (_GLOBAL_REENT) - { - local_clib._stdin = _GLOBAL_REENT->_stdin; - local_clib._stdout = _GLOBAL_REENT->_stdout; - local_clib._stderr = _GLOBAL_REENT->_stderr; - if (_GLOBAL_REENT->__cleanup) - local_clib.__cleanup = _cygtls::cleanup_early; - local_clib.__sglue._niobs = 3; - local_clib.__sglue._iobs = &_GLOBAL_REENT->__sf[0]; - } + if (_GLOBAL_REENT && _GLOBAL_REENT->__cleanup) + local_clib.__cleanup = _cygtls::cleanup_early; } thread_id = GetCurrentThreadId (); diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc index 5f460d8a5c78..6b816763e002 100644 --- a/winsup/cygwin/dcrt0.cc +++ b/winsup/cygwin/dcrt0.cc @@ -757,9 +757,7 @@ dll_crt0_0 () lock_process::init (); _impure_ptr = _GLOBAL_REENT; - _impure_ptr->_stdin = &_impure_ptr->__sf[0]; - _impure_ptr->_stdout = &_impure_ptr->__sf[1]; - _impure_ptr->_stderr = &_impure_ptr->__sf[2]; + _REENT_INIT_PTR_ZEROED (_GLOBAL_REENT); user_data->impure_ptr = _impure_ptr; user_data->impure_ptr_ptr = &_impure_ptr; diff --git a/winsup/cygwin/include/cygwin/config.h b/winsup/cygwin/include/cygwin/config.h index 71a216fbd16d..56fc326bd43e 100644 --- a/winsup/cygwin/include/cygwin/config.h +++ b/winsup/cygwin/include/cygwin/config.h @@ -66,6 +66,7 @@ extern inline struct _reent *__getreent (void) /* The following block of macros is required to build newlib correctly for Cygwin. Changing them in applications has no or not the desired effect. Just leave them alone. */ +#define _REENT_GLOBAL_STDIO_STREAMS 1 #define _READ_WRITE_RETURN_TYPE _ssize_t #define _READ_WRITE_BUFSIZE_TYPE size_t #define __LARGE64_FILES 1 diff --git a/winsup/cygwin/tlsoffsets.h b/winsup/cygwin/tlsoffsets.h [...skipped, just autogenerated data...] diff --git a/winsup/cygwin/tlsoffsets64.h b/winsup/cygwin/tlsoffsets64.h [...skipped, just autogenerated data...] Corinna