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.133.124]) by sourceware.org (Postfix) with ESMTPS id DE4C73858D20 for ; Thu, 17 Feb 2022 13:53:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org DE4C73858D20 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=1645105995; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=86NNGgpjsKF1764a3pUcakI1kO5gpI3qTAc6RMpNyxE=; b=eJnjy14hGCRv89SnteUZ6hQSdQGxUjuesZjSnQ6VcYYl24nAv/0+cg+QXiPYBcWeoUlhO7 b7Q7maorOUtIyT+Zt1hwc6omw6oICRxr80sYWOPGDnip+Ktj7cERlzqJy428437QAb9cu7 aySeFhnsb5pgoaQho0dGu4WqYTRVcxo= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-110-LjiuHZAeM8-aBymoz6l46A-1; Thu, 17 Feb 2022 08:53:12 -0500 X-MC-Unique: LjiuHZAeM8-aBymoz6l46A-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D91DC801B0C for ; Thu, 17 Feb 2022 13:53:11 +0000 (UTC) Received: from calimero.vinschen.de (unknown [10.36.112.2]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8069810A3BD9 for ; Thu, 17 Feb 2022 13:53:11 +0000 (UTC) Received: by calimero.vinschen.de (Postfix, from userid 500) id E9129A80896; Thu, 17 Feb 2022 14:53:09 +0100 (CET) Date: Thu, 17 Feb 2022 14:53:09 +0100 From: Corinna Vinschen To: newlib@sourceware.org Subject: Re: [PATCH 1/1] Make __sdidinit unused Message-ID: Reply-To: newlib@sourceware.org Mail-Followup-To: newlib@sourceware.org References: <20220217130520.27919-1-matthew.joyce@embedded-brains.de> <20220217130520.27919-2-matthew.joyce@embedded-brains.de> MIME-Version: 1.0 In-Reply-To: <20220217130520.27919-2-matthew.joyce@embedded-brains.de> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.3 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.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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, 17 Feb 2022 13:53:17 -0000 Hi Matt, this doesn't build on Cygwin. On Feb 17 14:05, Matthew Joyce wrote: > Remove dependency on __sdidinit member of struct _reent to check > object initialization. Like __sdidinit, the __cleanup member of > struct _reent is initialized in the __sinit() function. Checking > initialization against __cleanup serves the same purpose and will > reduce overhead in the __sfp() function in a follow up patch. > --- > [...] > diff --git a/winsup/cygwin/cygtls.cc b/winsup/cygwin/cygtls.cc > index 1a2213d1f..239a9d7e1 100644 > --- a/winsup/cygwin/cygtls.cc > +++ b/winsup/cygwin/cygtls.cc > @@ -60,8 +60,8 @@ _cygtls::init_thread (void *x, DWORD (*func) (void *, void *)) > local_clib._stdin = _GLOBAL_REENT->_stdin; > local_clib._stdout = _GLOBAL_REENT->_stdout; > local_clib._stderr = _GLOBAL_REENT->_stderr; > - local_clib.__sdidinit = _GLOBAL_REENT->__sdidinit ? -1 : 0; > - local_clib.__cleanup = _GLOBAL_REENT->__cleanup; > + local_clib.__cleanup = _GLOBAL_REENT->__cleanup ? > + (void *)(uintptr_t)-1 : NULL; CXX cygtls.o winsup/cygwin/cygtls.cc: In member function ‘void _cygtls::init_thread(void*, DWORD (*)(void*, void*))’: winsup/cygwin/cygtls.cc:63:59: error: invalid conversion from ‘void*’ to ‘void (*)(_reent*)’ [-fpermissive] 63 | local_clib.__cleanup = _GLOBAL_REENT->__cleanup ? | ^ | | | void* > diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc > index f3d09c169..16ca5888c 100644 > --- a/winsup/cygwin/dcrt0.cc > +++ b/winsup/cygwin/dcrt0.cc > @@ -824,15 +824,13 @@ main_thread_sinit () > [...] > - to _REENT here again. */ > - _REENT->__sdidinit = -1; > - _REENT->__cleanup = _GLOBAL_REENT->__cleanup; > + To fix this issue we set __cleanup to -1 here. */ > + _REENT->__cleanup = (void *)(uintptr_t)-1; winsup/cygwin/dcrt0.cc: In function ‘void main_thread_sinit()’: winsup/cygwin/dcrt0.cc:833:23: error: invalid conversion from ‘void*’ to ‘void (*)(_reent*)’ [-fpermissive] 833 | _REENT->__cleanup = (void *)(uintptr_t)-1; | ^~~~~~~~~~~~~~~~~~~~~ | | | void* I suggest this change, which also includes a matching change to thread.cc, to be type-safe: diff --git a/winsup/cygwin/cygtls.cc b/winsup/cygwin/cygtls.cc index 239a9d7e1f51..e80fbce5f3e8 100644 --- a/winsup/cygwin/cygtls.cc +++ b/winsup/cygwin/cygtls.cc @@ -60,8 +60,9 @@ _cygtls::init_thread (void *x, DWORD (*func) (void *, void *)) local_clib._stdin = _GLOBAL_REENT->_stdin; local_clib._stdout = _GLOBAL_REENT->_stdout; local_clib._stderr = _GLOBAL_REENT->_stderr; - local_clib.__cleanup = _GLOBAL_REENT->__cleanup ? - (void *)(uintptr_t)-1 : NULL; + local_clib.__cleanup = (void (*) (struct _reent *)) + (_GLOBAL_REENT->__cleanup + ? (void *) -1 : NULL); local_clib.__sglue._niobs = 3; local_clib.__sglue._iobs = &_GLOBAL_REENT->__sf[0]; } diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc index 16ca5888c28a..7f26c6304030 100644 --- a/winsup/cygwin/dcrt0.cc +++ b/winsup/cygwin/dcrt0.cc @@ -830,7 +830,7 @@ main_thread_sinit () read or written in the first stdio function call in the main thread. To fix this issue we set __cleanup to -1 here. */ - _REENT->__cleanup = (void *)(uintptr_t)-1; + _REENT->__cleanup = (void (*) (struct _reent *)) -1; } /* Take over from libc's crt0.o and start the application. Note the diff --git a/winsup/cygwin/thread.cc b/winsup/cygwin/thread.cc index 3c3a2f3b3a52..21b2dbe4686e 100644 --- a/winsup/cygwin/thread.cc +++ b/winsup/cygwin/thread.cc @@ -564,7 +564,7 @@ pthread::exit (void *value_ptr) mutex.unlock (); } - if (_my_tls.local_clib.__cleanup == (void *)(uintptr_t)-1) + if (_my_tls.local_clib.__cleanup == (void (*) (struct _reent *)) -1) _my_tls.local_clib.__cleanup = NULL; _reclaim_reent (_REENT); With these changes, GTG. Thx, Corinna