From owner-freebsd-arch@freebsd.org Mon Feb 11 13:06:44 2019 Return-Path: Delivered-To: freebsd-arch@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7AC6614D6788 for ; Mon, 11 Feb 2019 13:06:44 +0000 (UTC) (envelope-from deischen@freebsd.org) Received: from mailman.ysv.freebsd.org (mailman.ysv.freebsd.org [IPv6:2001:1900:2254:206a::50:5]) by mx1.freebsd.org (Postfix) with ESMTP id 172F46C997 for ; Mon, 11 Feb 2019 13:06:44 +0000 (UTC) (envelope-from deischen@freebsd.org) Received: by mailman.ysv.freebsd.org (Postfix) id CC30814D6784; Mon, 11 Feb 2019 13:06:43 +0000 (UTC) Delivered-To: arch@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B96FE14D6783 for ; Mon, 11 Feb 2019 13:06:43 +0000 (UTC) (envelope-from deischen@freebsd.org) Received: from mail.netplex.net (mail.netplex.net [204.213.176.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "*.netplex.net", Issuer "RapidSSL RSA CA 2018" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 5E63B6C994 for ; Mon, 11 Feb 2019 13:06:43 +0000 (UTC) (envelope-from deischen@freebsd.org) Received: from sea.ntplx.net (sea.ntplx.net [204.213.176.11]) by mail.netplex.net (8.15.1/8.15.1/NETPLEX) with ESMTP id x1BD5XHx061910; Mon, 11 Feb 2019 08:05:33 -0500 X-Virus-Scanned: by AMaViS and Clam AntiVirus (mail.netplex.net) X-Greylist: Message whitelisted by DRAC access database, not delayed by milter-greylist-4.4.3 (mail.netplex.net [204.213.176.9]); Mon, 11 Feb 2019 08:05:33 -0500 (EST) Date: Mon, 11 Feb 2019 08:05:33 -0500 (EST) From: Daniel Eischen X-X-Sender: eischen@sea.ntplx.net Reply-To: Daniel Eischen To: Poul-Henning Kamp cc: arch@freebsd.org Subject: Re: switch to non-zero PTHREAD_*_INITIALIZER In-Reply-To: <92707.1549878222@critter.freebsd.dk> Message-ID: References: <92707.1549878222@critter.freebsd.dk> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Rspamd-Queue-Id: 5E63B6C994 X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-6.96 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.96)[-0.959,0]; REPLY(-4.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Feb 2019 13:06:44 -0000 On Mon, 11 Feb 2019, Poul-Henning Kamp wrote: > Right now most of our PTHREAD_*_INITIALIZER macros are defined as NULL. > > This is a bad choice from a code quality point of view, because it means > that > > pthread_t my_mutex; > > and > > pthread_t my_mutes = PTHREAD_MUTEX_INITIALIZER; > > act the same, which they are not. > > I suggest that we should change the macros to a non-NULL value, and > add a check for NULL values which emit a warning about the lack of > initialization. > > Comments ? You'll get warnings from anything that hasn't be rebuilt with the new initializers, including other languages that have overlays to the same C structures (well, really ours are pointers to structs). I'm not really against this, but I'd rather see our mutex, condvar, etc, be real structs instead of pointers to structs. This would hopefully get rid of the whole malloc mess inside libthr and simplify pthread_XXX_setpshared(). I'd think that we've evolved the pthread API enough to pick some large enough storage size for our structs such that we won't have to change it again. Of course, even with versioned libraries, this change would probably require a library version bump. -- DE