From owner-svn-src-head@freebsd.org Fri May 27 09:22:37 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1C4DFB4A67F; Fri, 27 May 2016 09:22:37 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail106.syd.optusnet.com.au (mail106.syd.optusnet.com.au [211.29.132.42]) by mx1.freebsd.org (Postfix) with ESMTP id 9E42A1A83; Fri, 27 May 2016 09:22:36 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from c122-106-149-109.carlnfd1.nsw.optusnet.com.au (c122-106-149-109.carlnfd1.nsw.optusnet.com.au [122.106.149.109]) by mail106.syd.optusnet.com.au (Postfix) with ESMTPS id 6B62C3C3F10; Fri, 27 May 2016 19:22:31 +1000 (AEST) Date: Fri, 27 May 2016 19:22:31 +1000 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Jilles Tjoelker cc: John Baldwin , Alan Somers , Peter Wemm , "src-committers@freebsd.org" , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Subject: Re: svn commit: r300557 - head/usr.sbin/apmd In-Reply-To: <20160526175420.GA31199@stack.nl> Message-ID: <20160527181051.Y2719@besplex.bde.org> References: <201605240315.u4O3FkMt001717@repo.freebsd.org> <2084098.Ir36lcS1Gf@ralph.baldwin.cx> <20160526175420.GA31199@stack.nl> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.1 cv=EfU1O6SC c=1 sm=1 tr=0 a=R/f3m204ZbWUO/0rwPSMPw==:117 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=kj9zAlcOel0A:10 a=6I5d2MoRAAAA:8 a=BbAJd8o89xd2n4L0m28A:9 a=CjuIK1q_8ugA:10 a=IjZwj45LgO3ly-622nXo:22 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 May 2016 09:22:37 -0000 On Thu, 26 May 2016, Jilles Tjoelker wrote: > On Tue, May 24, 2016 at 08:52:32AM -0700, John Baldwin wrote: >> On Monday, May 23, 2016 09:24:41 PM Alan Somers wrote: >>> On Mon, May 23, 2016 at 9:15 PM, Peter Wemm wrote: > >>>> Author: peter >>>> Date: Tue May 24 03:15:46 2016 >>>> New Revision: 300557 >>>> URL: https://svnweb.freebsd.org/changeset/base/300557 > >>>> Log: >>>> It seems is a new prerequisite for after >>>> r300539. Attempt to fix the build for i386. > >>>> Modified: >>>> head/usr.sbin/apmd/apmd.c >>>> head/usr.sbin/apmd/apmdlex.l >>>> head/usr.sbin/apmd/apmdparse.y > >>> Are you sure this is necessary, even after 300544? > >> Actually, we try to avoid nested includes when possible for userland, >> so I'd be inclined to drop the nested include and just >> add to the places that need it. Userland code in the >> base system is supposed to have or as the >> first #include anyway (which apmd was not following), so any fixes to >> userland are probably style fixes anyway. > > This is traditional BSD convention, but headers specified by POSIX work > differently. POSIX headers can be included alone, so files that only > include POSIX headers rarely need #include . This often > causes some ugliness in the header file to use hidden names for things > to reduce namespace pollution. > > Since is not specified by POSIX, it is not required to > work without prerequisites. However, its man page always documented that it has no prequisites. Except, its man page has a cryptic reference to malloc(3). This used to mean "bit_alloc() allocates storage using calloc(), but we're not telling you this detail, or that you must include to get calloc() declared iff you use bit_alloc(). It now means "bit_alloc(), allocates storage using calloc(), but we're not telling you this detail, or that we now include as undocumented namespace pollution since this is the quickest fix for namespace problems caused by changing the implementation of bit_alloc() from a macro to an inline function". sys/bitstring.h has the following old namespace problems: - use of calloc(), and intentionally keeping itself "clean" by not declaring this. This was a smaller problem when bit_alloc() was a macro. and the following new namespace problems: - use of ffsl(), and intentionally keeping itself "clean" by not declaring this. Just declaring this should work. If ffsl() is not translated by the compiler to __builtin_ffsl(), too bad. - use of __bitcountl(), and intentionally keeping itself "clean" by not declaring this. The builtin is spelled __builtin_popcountl() but we wrap this to our spelling. The underscores might prevent translation to the builtin (probably only with strict compiler flags) and the spelling change certainly prevent it. This is technically better than polluting the application namespace like using ffsl() does, and the spelling change gives us more control (which we use to provide 50 lines of compatibility cruft), but it means that just declaring the function won't work. It is only defined in . Thus gives as a new prerequisite and thus mostly defeats the otherwise mostly careful-to-a-fault anti-pollution measures in :-(. sys/bitstring.h uses unsigned long instead of a possibly-better type like __uregister_t or __uintmax_t partly to avoid pollution. - undocumented include of as a quick fix for the previous problem. Plain bitstring.h has the following new namespace pollutions: - undocumented include of as a quick fix for the calloc() problem - undocumented include of as a quick fix for the ffsl() problem These headers are too careful about pollution to include , so they don't accidentally define __bitcountl(). Bruce