From owner-freebsd-threads@FreeBSD.ORG Fri Sep 24 09:00:15 2010 Return-Path: Delivered-To: freebsd-threads@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C76D91065693 for ; Fri, 24 Sep 2010 09:00:15 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id B6ED48FC1A for ; Fri, 24 Sep 2010 09:00:15 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id o8O90FxT015182 for ; Fri, 24 Sep 2010 09:00:15 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id o8O90FYm015166; Fri, 24 Sep 2010 09:00:15 GMT (envelope-from gnats) Date: Fri, 24 Sep 2010 09:00:15 GMT Message-Id: <201009240900.o8O90FYm015166@freefall.freebsd.org> To: freebsd-threads@FreeBSD.org From: Thomas Mueller Cc: 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 Reply-To: Thomas Mueller List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Sep 2010 09:00:15 -0000 The following reply was made to PR threads/150889; it has been noted by GNATS. From: Thomas Mueller To: John Baldwin Cc: freebsd-threads@freebsd.org, freebsd-gnats-submit@freebsd.org, Christopher Faylor Subject: Re: threads/150889: PTHREAD_MUTEX_INITIALIZER + pthread_mutex_destroy() == EINVAL Date: Fri, 24 Sep 2010 10:38:05 +0200 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