Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 17 Nov 2012 04:24:06 +1100 (EST)
From:      Bruce Evans <brde@optusnet.com.au>
To:        Konstantin Belousov <kostikbel@gmail.com>
Cc:        svn-src-head@freebsd.org, mdf@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org
Subject:   Re: svn commit: r243134 - head/sys/sys
Message-ID:  <20121117040901.I3439@besplex.bde.org>
In-Reply-To: <20121116160539.GN73505@kib.kiev.ua>
References:  <201211160625.qAG6PLd2032062@svn.freebsd.org> <CAMBSHm_xwP5S8ERXYL%2Bsw%2BBAfgTAss9i0EGoX5%2B1Hy40PhfXbg@mail.gmail.com> <20121116160539.GN73505@kib.kiev.ua>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, 16 Nov 2012, Konstantin Belousov wrote:

> On Fri, Nov 16, 2012 at 08:02:39AM -0800, mdf@FreeBSD.org wrote:
>> On Thu, Nov 15, 2012 at 10:25 PM, Konstantin Belousov <kib@freebsd.org> wrote:
>>> Author: kib
>>> Date: Fri Nov 16 06:25:20 2012
>>> New Revision: 243134
>>> URL: http://svnweb.freebsd.org/changeset/base/243134
>>>
>>> Log:
>>>   Alphabetically reorder the forward-declarations of the structures.
>>>   Add the declaration for enum idtype, to be used later.
>>
>> Forward declarations of enums isn't an ISO C feature, but a gcc
>> extension.  While the kernel uses many gcc extensions, it hides most
>> under a #define so unsupported compilers can continue along.  This
>> unsupported feature can't be hidden.

Ugh.  We discussed the unportability of enums in APIs when cleaning this
up.  kib said that the size of an enum type is an ABI standard for i386
and amd64.  I don't quite agree for i386, and we didn't discuss other
arches.  The size of an enum type must be fixed for the gcc extension
to be possible.

gcc -std=c99 -pedantic generates a warning for forward enum declaration.
Long ago, I routinely tested with -pedantic and committed fixes for all
the things that it found if they were not too hard to fix.

>> Does the forward declaration prevent another warning?
>
> It allows to prevent the namespace pollution from sys/wait.h idtype_t, needed
> due to the kern_wait6() declaration.

syscallsubr.h and especially sysproto.h have lots of other namespace
pollution.  My version of sysproto.h reduces the pollution to just
<sys/_sigset.h> using 6 #define hacks and 1 clean #include change to
reduce 5 polluting headers and 1 non-polluting one to 1 different
non-polluting one.  The #define hacks can't work for enums.

When I worked on reducing the pollution in sysproto.h in its automatic
generation, I got it down to <sys/signal.h> and not much more.
<sys/_sigset.h> because available later, but -current still has the
full pollution of <sys/signal.h> and much more.  Non-auto-generated
headers like syscallsubr.h are easier to clean.

Bruce



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20121117040901.I3439>