From owner-freebsd-standards@FreeBSD.ORG Mon Nov 15 05:06:18 2010 Return-Path: Delivered-To: standards@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D8E87106566B for ; Mon, 15 Nov 2010 05:06:18 +0000 (UTC) (envelope-from yanegomi@gmail.com) Received: from mail-wy0-f182.google.com (mail-wy0-f182.google.com [74.125.82.182]) by mx1.freebsd.org (Postfix) with ESMTP id 63B248FC1C for ; Mon, 15 Nov 2010 05:06:18 +0000 (UTC) Received: by wyb36 with SMTP id 36so2157289wyb.13 for ; Sun, 14 Nov 2010 21:06:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:sender:received :in-reply-to:references:date:x-google-sender-auth:message-id:subject :from:to:cc:content-type:content-transfer-encoding; bh=DT4TGd1eCF49c24Hl8oxeidApMRwe0OIFhimZZlBEgY=; b=BKzpvqiYxEiPO9oR8cetpjDckSqGwhE79F5I/TWA+zBdBSuRx6SgSf+IjQfS8W7jnT Rr0vSHljtYIiCVB+7OHq7vKuR13vKGp2ijjyGKq5BLqADCgLQatDAOewjzAr9ciJgbgo vv9dY2xtiVNpUt41S+tCcfcF92VYbtZUdmJ30= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; b=pxu4tQE3Kq/6JjZN48YG4MSnwxP/l2YWloYdk39d+TbP9srgJg/MfVoXIhqXCRlc/9 EiiWeV3yh9Kkj9bbhHokClhm3tFA78uFUznRoOHpywbvhU+eCWnxx6KZY2EOgELcMV+l +1n7wksgrWU1rLoc/v8aqHM5nQ6rEppa9Bhm4= MIME-Version: 1.0 Received: by 10.216.46.200 with SMTP id r50mr6760479web.45.1289797577203; Sun, 14 Nov 2010 21:06:17 -0800 (PST) Sender: yanegomi@gmail.com Received: by 10.216.198.27 with HTTP; Sun, 14 Nov 2010 21:06:17 -0800 (PST) In-Reply-To: <20101109015704.L1243@besplex.bde.org> References: <20101109015704.L1243@besplex.bde.org> Date: Sun, 14 Nov 2010 21:06:17 -0800 X-Google-Sender-Auth: gcxNRZAKs13UDkQjiwuNg7jSHdU Message-ID: From: Garrett Cooper To: Bruce Evans Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: standards@freebsd.org Subject: Re: Question about non-__BSD_VISIBLE guarded CLOCK_* constants X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 15 Nov 2010 05:06:18 -0000 On Mon, Nov 8, 2010 at 7:59 AM, Bruce Evans wrote: > On Sun, 7 Nov 2010, Garrett Cooper wrote: > >> =A0 None of the following constants in time.h are guarded by >> __BSD_VISIBLE, __FreeBSD__, etc, even though other sections of the >> file are blocked off that way (and the comments suggest that they're >> FreeBSD-specific). I was wondering why that's the case... > > It is because the other sections were written by standards-aware persons. > >> #define CLOCK_UPTIME =A0 =A05 =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* FreeBSD-spe= cific. */ >> #define CLOCK_UPTIME_PRECISE =A0 =A07 =A0 =A0 =A0 /* FreeBSD-specific. *= / >> #define CLOCK_UPTIME_FAST =A0 =A0 =A0 8 =A0 =A0 =A0 /* FreeBSD-specific.= */ >> #define CLOCK_REALTIME_PRECISE =A09 =A0 =A0 =A0 /* FreeBSD-specific. */ >> #define CLOCK_REALTIME_FAST =A0 =A0 10 =A0 =A0 =A0/* FreeBSD-specific. *= / >> #define CLOCK_MONOTONIC_PRECISE 11 =A0 =A0 =A0/* FreeBSD-specific. */ >> #define CLOCK_MONOTONIC_FAST =A0 =A012 =A0 =A0 =A0/* FreeBSD-specific. *= / >> #define CLOCK_SECOND =A0 =A013 =A0 =A0 =A0 =A0 =A0 =A0 =A0/* FreeBSD-spe= cific. */ > > Defining these without using __BSD_VISBLE is just a style bug, since the > CLOCK_ prefix is reserved in , but FreeBSD normally ifdefs > extensions that use reserved prefixes anyway (e.g., FreeBSD-specific > signal numbers at least used to be ifdefed to a fault in . > > The definitions themselves have lots of style bugs: > - space instead of tab after #define (all tabs were corrupted in the mail= , > =A0except these are corrupt in the file) > - macro values don't line up, although they are indented with tabs > - comment duplicated ad nauseum > - there is now an id 14. =A0It is missing the comment, and seems to be > =A0undocumented. > >> =A0 Also, they're blocked off by #if !defined(CLOCK_REALTIME) && >> __POSIX_VISIBLE >=3D 200112 , which doesn't seem to make sense, given >> that it's an "advanced realtime" feature, according to POSIX 2008. > > Re-quoting everything to get more context. > > % /* These macros are also in sys/time.h. */ > > is considerably more broken than here. =A0It defines all of > these macros unconditionally, and also includes in the !_KERNEL > case. =A0Thus including the POSIX header gives massive names= pace > pollution. > > % #if !defined(CLOCK_REALTIME) && __POSIX_VISIBLE >=3D 200112 > % #define CLOCK_REALTIME =A0 =A0 =A0 =A00 > % #ifdef __BSD_VISIBLE > % #define CLOCK_VIRTUAL 1 > % #define CLOCK_PROF =A0 =A02 > % #endif > % #define CLOCK_MONOTONIC =A0 =A0 =A0 4 > /* These macros are also in sys/time.h. */ > #define CLOCK_MONOTONIC 4 > #define CLOCK_UPTIME =A0 =A05 =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* FreeBSD-spec= ific. */ > #define ... > #endif /* !defined(CLOCK_REALTIME) && __POSIX_VISIBLE >=3D 200112 */ > > The CLOCK_REALTIME part of this does nothing except partially break > automatic checking that the defines here are the same as the ones in > : > - if is not included before here, then CLOCK_REALTIME should= n't > =A0be defined yet, so it has no effect in this ifdef > - if is =A0 =A0 included before here, then CLOCK_REALTIME > =A0is defined now, so its effect in this ifdef is to prevent repeating if= defs > =A0that should be the same. =A0Repeated ifdefs are a very small part of h= eader > =A0bloat, so it is hardly worth avoiding them, and not avoiding them give= s the > =A0feature of checking that they really are repeated. =A0I think the repe= titions > =A0are all indentical, including their style bugs and whitespace that wou= ld > =A0not be checked. > - if is not included before here, but is included later, the= n > =A0CLOCK_REALTIME etc. gets declared here, and since has no > =A0similar ifdefs, it gets defined again later. =A0Thus the automatic che= cking > =A0is only partially broken. > > As you noticed, the __POSIX_VISIBLE part of this has the wrong version > number > at best. =A0CLOCK_REALTIME dates from POSIX.4 in ~1994 (it is in my POSIX= .4 > book published in 1995, and in the 1996 POSIX standard). =A0FreeBSD doesn= 't > try to track old versions of POSIX very carefully, except original POSIX, > but it normally makes features that appeared in in-between POSIXes visibl= e > by default by putting them under __BSD_VISIBLE. > > So the correct ifdefs here aresomething like __BSD_VISIBLE || > POSIX_VISIBLE >=3D 199309 (check the latter) for the whole block, and > __BSD_VISIBLE for the sub-block consisting of FreeBSD extensions. > Since the organization is poor (historical, giving random alphabetical an= d > numericl order), there are actually several sub-blocks: > - CLOCK_MONOTONIC seems to be new in POSIX.1-2001. =A0Thus the current if= def > =A0is partially correct for it. =A0The rest of the file has careful ifdef= s for > =A01993 POSIX, so perhaps it is worth being equally careful for > CLOCK_REALTIME. > - the BSD extensions CLOCK_VIRTUAL and CLOCK_PROF are already in a > =A0__BSD_VISIBLE block. =A0Then there seems to be space for expansion (a > =A0whole 1 id =3D 3). =A0Then there is the whole 1 new id =3D 4 for 2001 = POSIX. > =A0Then there is a FreeBSD-specific block (ids 5-14). =A0Too much bloat f= or me. Looks like I got the isolation working properly: # gcc -D_BSD_SOURCE -o ~gcooper/test_clock_uptime ~gcooper/test_clock_uptim= e.c # ~gcooper/test_clock_uptime 100031 661918304 # gcc -D_POSIX_C_SOURCE=3D200809 -D_POSIX_SOURCE -o ~gcooper/test_clock_uptime ~gcooper/test_clock_uptime.c /home/gcooper/test_clock_uptime.c: In function 'main': /home/gcooper/test_clock_uptime.c:10: error: 'CLOCK_UPTIME' undeclared (first use in this function) /home/gcooper/test_clock_uptime.c:10: error: (Each undeclared identifier is reported only once /home/gcooper/test_clock_uptime.c:10: error: for each function it appears i= n.) Removing time.h looks like a mini-project in and of itself, as I've had to go fix a handful of files in libc that were looking for clock or timer definitions that were defined in time.h according to POSIX, found a few bugs elsewhere when running buildworld, etc. I'll be submitting patches for all of these items eventually, but it looks like the breakage is potentially quite large. Thanks, -Garrett