From owner-freebsd-threads@FreeBSD.ORG Fri Sep 24 08:59:40 2010 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BE1BD1065672; Fri, 24 Sep 2010 08:59:40 +0000 (UTC) (envelope-from tmueller@sysgo.com) Received: from mail.sysgo.com (mail.sysgo.com [195.145.229.155]) by mx1.freebsd.org (Postfix) with ESMTP id 7E75B8FC17; Fri, 24 Sep 2010 08:59:40 +0000 (UTC) Received: from lantia.sysgo.com (unknown [172.22.2.7]) by mail.sysgo.com (Postfix) with ESMTP id 36D3414119; Fri, 24 Sep 2010 10:43:48 +0200 (CEST) Received: by lantia.sysgo.com (Postfix, from userid 113) id 135D05A295; Fri, 24 Sep 2010 10:43:48 +0200 (CEST) Received: from tmu.ulm.sysgo.com (tmu.ulm.sysgo.com [172.30.3.10]) by lantia.sysgo.com (Postfix) with ESMTP id E59C95A281; Fri, 24 Sep 2010 10:43:47 +0200 (CEST) Date: Fri, 24 Sep 2010 10:38:05 +0200 From: Thomas Mueller To: John Baldwin Message-ID: <20100924103805.75c16735@tmu.ulm.sysgo.com> In-Reply-To: <201009231414.50271.jhb@freebsd.org> References: <201009231733.o8NHXuao082524@www.freebsd.org> <201009231414.50271.jhb@freebsd.org> Organization: SYSGO AG X-Mailer: Claws Mail 3.7.6 (GTK+ 2.20.1; amd64-portbld-freebsd8.1) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: freebsd-gnats-submit@freebsd.org, Christopher Faylor , freebsd-threads@freebsd.org Subject: Re: threads/150889: PTHREAD_MUTEX_INITIALIZER + pthread_mutex_destroy() == EINVAL X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Sep 2010 08:59:40 -0000 On Thu, 23 Sep 2010 14:14:50 -0400, John Baldwin wrote: > On Thursday, September 23, 2010 1:33:56 pm Christopher Faylor wrote: > > In cases where default mutex attributes are appropriate, the macro > > PTHREAD_MUTEX_INITIALIZER can be used to initialize mutexes that are statically > > allocated. The effect shall be equivalent to dynamic initialization by a call to > > pthread_mutex_init() with parameter attr specified as NULL, except that no error > > checks are performed. > > I suppose that is true, but I think this is also probably buggy code if you > are doing this. The use case for PTHREAD_MUTEX_INITALIZER is static > initialization of static objects to ease adding locking to C libraries where > constructors are not easy. Note that future standard text might drop the "statically allocated" part in the pthread_mutex_init() description, see also http://www.austingroupbugs.net/view.php?id=70 -- Thomas Mueller