From owner-freebsd-threads@FreeBSD.ORG Mon Mar 19 17:33:55 2012 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 7B925106564A; Mon, 19 Mar 2012 17:33:55 +0000 (UTC) (envelope-from kubito@gmail.com) Received: from mail-yx0-f182.google.com (mail-yx0-f182.google.com [209.85.213.182]) by mx1.freebsd.org (Postfix) with ESMTP id 1E94E8FC18; Mon, 19 Mar 2012 17:33:54 +0000 (UTC) Received: by yenl9 with SMTP id l9so6845349yen.13 for ; Mon, 19 Mar 2012 10:33:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; bh=4UsupB9tDCSpvMNaibXUq7JZG4Wx2MShhny1ffNm0KE=; b=Qizbu6HKWzABz3Xu/r/wbKMyic7WLw4ifPAsa0OcEWKVRTLwwhIgPEsnqVjZnibeB2 yHA0QEIQQX9Ii3BP0mXmaaQ+kCtQWleOJDe9Z40z8sXzVCxPrRfcSK3aMTWJGJ/p1Q7r DcjhPHH8K1Lq22cSFH+nxGammNdBVCV25yxIK68BtwRc0M661I3NHmuQ9pWbwUm6SrAx 7i3NODuY1UqGit8hWecjsyAHt1/GunzUIlVYJT6a+rayI9QAdrUP6Tiw9xdXULrhLBQS hr3gAW+vpkXHIRkuRupsNXys8QG4msZxBKZjeZT9fr1OyYOym8stodKEzUZI4TYx06JZ 99jQ== Received: by 10.60.18.137 with SMTP id w9mr14666398oed.7.1332178434262; Mon, 19 Mar 2012 10:33:54 -0700 (PDT) Received: from rachacuca.gmail.com (li113-135.members.linode.com. [69.164.198.135]) by mx.google.com with ESMTPS id 8sm13663132obv.19.2012.03.19.10.33.52 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 19 Mar 2012 10:33:53 -0700 (PDT) Sender: Raphael Kubo da Costa From: Raphael Kubo da Costa To: Bruce Evans References: <87haxlh7ir.fsf@FreeBSD.org> <20120319194821.H1024@besplex.bde.org> Date: Mon, 19 Mar 2012 14:34:51 -0300 In-Reply-To: <20120319194821.H1024@besplex.bde.org> (Bruce Evans's message of "Mon, 19 Mar 2012 20:02:11 +1100 (EST)") Message-ID: <83haxk8pfo.fsf@FreeBSD.org> User-Agent: Gnus/5.130004 (Ma Gnus v0.4) Emacs/23.4 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Cc: freebsd-standards@FreeBSD.org, freebsd-threads@FreeBSD.org Subject: Re: Should __clockid_t be used instead of clockid_t in pthread.h? 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: Mon, 19 Mar 2012 17:33:55 -0000 Bruce Evans writes: > On Sun, 18 Mar 2012, Raphael Kubo da Costa wrote: > >> Hi there. >> >> I'm trying to build an unstable glib version here, and one of their >> tests fails to build due to them #defining _POSIX_C_SOURCE to 0 and >> then #including , which produces the following error on my >> 8-STABLE machine: > > This gives undefined behaviour. > >> /usr/include/pthread.h:184: error: expected declaration specifiers or '...' before 'clockid_t' >> /usr/include/pthread.h:187: error: expected declaration specifiers or '...' before 'clockid_t' >> /usr/include/pthread.h:203: error: expected declaration specifiers or '...' before 'clockid_t' >> >> pthread.h gets its definition of clockid_t from time.h, but time.h only >> creates the typedef if __POSIX_VISIBLE is >= 199309. Using __clockid_t >> instead of clockid_t in the function prototypes works fine. >> >> Should the prototypes be changed? > > time.h is a standard C header, so not defining clockid_t in it when POSIX > extensions are disabled is correct. > > pthread.h is a not-so-old POSIX header, so it can assume that > __POSIX_VISIBLE is >= 199309. Including it when POSIX is not visible, > or when only an older version of POSIX is visible, is just nonsense > and can have any result, like the one here. While using __clockid_t > in in might make it sort of work, it would remain quite broken. POSIX > requires that pthread.h shall make all the namespace pollution in > time.h (and some other headers) visible. This is a bug in POSIX. It > actually requires that pthread.h shall make all the [POSIX] symbols > in time.h visible. pthread.h just includes time.h to get all of these > symbols, and becomes broken if ones like clockid_t are not declared. > If pthread.h is actually used, then programs using it will actually > need some of the symbols like clockid_t from time.h and break when > they don't explicitly include time.h. Thank you for the detailed explanation. I've filed a bug in glib's Bugzilla [1] with a proposed fix that should work on both FreeBSD and Linux. [1] https://bugzilla.gnome.org/show_bug.cgi?id=672406