From owner-svn-src-all@FreeBSD.ORG Sun Nov 20 03:49:10 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6D015106564A; Sun, 20 Nov 2011 03:49:10 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail07.syd.optusnet.com.au (mail07.syd.optusnet.com.au [211.29.132.188]) by mx1.freebsd.org (Postfix) with ESMTP id F3B598FC08; Sun, 20 Nov 2011 03:49:09 +0000 (UTC) Received: from c211-28-227-231.carlnfd1.nsw.optusnet.com.au (c211-28-227-231.carlnfd1.nsw.optusnet.com.au [211.28.227.231]) by mail07.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id pAK3n6ua015859 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 20 Nov 2011 14:49:07 +1100 Date: Sun, 20 Nov 2011 14:49:06 +1100 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: David Schultz In-Reply-To: <20111114191914.GA58676@zim.MIT.EDU> Message-ID: <20111120140428.A1000@besplex.bde.org> References: <201111131618.pADGIm2n099696@svn.freebsd.org> <20111114082129.GA1596@mole.fafoe.narf.at> <4EC0E6C2.4010509@FreeBSD.org> <20111114180235.GA58284@zim.MIT.EDU> <3B8C1412-E18D-47E3-A09D-4847DD078963@FreeBSD.org> <20111114191914.GA58676@zim.MIT.EDU> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: src-committers@freebsd.org, David Chisnall , svn-src-all@freebsd.org, Dimitry Andric , Stefan Farfeleder , svn-src-head@freebsd.org Subject: Re: svn commit: r227487 - head/include X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 20 Nov 2011 03:49:10 -0000 On Mon, 14 Nov 2011, David Schultz wrote: > On Mon, Nov 14, 2011, David Chisnall wrote: >> On 14 Nov 2011, at 18:02, David Schultz wrote: >> >>> On Mon, Nov 14, 2011, Dimitry Andric wrote: >>>> On 2011-11-14 09:21, Stefan Farfeleder wrote: >>>>> On Sun, Nov 13, 2011 at 04:18:48PM +0000, David Chisnall wrote: >>>>>> Author: theraven >>>>>> Date: Sun Nov 13 16:18:48 2011 >>>>>> New Revision: 227487 >>>>>> URL: http://svn.freebsd.org/changeset/base/227487 >>>>>> >>>>>> Log: >>>>>> The spec says that FILE must be defined in wchar.h, but it wasn't. It >>>>>> is now. Also hide some macros in C++ mode that will break C++ >>>>>> namespaced calls. >>>>>> >>>>>> Approved by: dim (mentor) >>>>> >>>>> I think this change is wrong. Whic spec are you referring to? C99 >>>>> defines FILE only in 7.19.1#2 (stdio.h). In other headers FILE is used >>>>> as parameter type for functions but that does not mean it is exported to >>>>> user space. Also, this change doesn't even declare `FILE'. It only declares an incomplete struct for `FILE', just like the old version except for a different spelling which gives namespace pollution that was carefully avoided. >>>> http://pubs.opengroup.org/onlinepubs/007908799/xsh/wchar.h.html Just another bug in POSIX. Another bug in it is its wording, which is either too fuzzy or too strict. It says that FILE is defined (sic) as "described in ". If this is interpreted strictly, then it says that must declare FILE completely iff declares it completely. FILE should be opaque, so it should not be declared completely in either, but FreeBSD still supports old optimized inline or macro versions for a few of the interfaces in , so it must declare FILE completely in . Thus POSIX strictly requires FILE to be declared completely in too. But nothing in needs to dereference FILE, so doesn't need to declare it completely. I doubt that POSIX is so broken as to require this intentionally. >>> It's a niggling detail, but that's an extension to the C standard, >>> so properly speaking, it belongs in an >>> #if __POSIX_VISIBLE >= 200809 || XSI_VISIBLE >>> (or something like that). The formals were struct __sFILE * >>> instead of FILE * for that reason -- see r103177. >>> >>> P.S. You're looking at a very old version of POSIX. Check out: >>> http://pubs.opengroup.org/onlinepubs/9699919799/ Too hard to search using lynx. >> The C99 and C1x specifications both seem to require stdio.h to be included before wchar.h. I think this therefore places including wchar.h and not stdio.h in the category of undefined (or, at least, not defined) behaviour, so we are free to do anything in this case. I would say that accepting the code and working as the programmer expected is the least harmful thing to do here. This is what Darwin libc does (actually, it #includes stdio.h in wchar.h). Just another bug in Darwin. FreeBSD had the full namespace pollution from too, until this was fixed in r103177. > The C99 standard has plenty of examples of programs including > but not . The latter is only required to call > the functions that take a FILE * parameter. It's mostly an Not even that in FreeBSD (but C99 and portability requires it). The functions can be called without knowing a complete declaration of FILE or anything else in . E.g., getwc(NULL), or more usefully, getwc(fp) where fp is a FILE * passed as a parameter to the function that calls getwc(). This depends on the implementation detail that none of the functions dereferences FILE *. If we want to punish unportable callers that don't include strictly before including and using one of the functions, perhaps that can be arranged. > academic point because no sane programmer would ever create a new > type named FILE, but FreeBSD actually did right by C99 before you > reverted r103177. Bruce