On Fri, 16 Nov 2012, Konstantin Belousov wrote:

On Fri, Nov 16, 2012 at 08:02:39AM -0800, m...@freebsd.org wrote:
On Thu, Nov 15, 2012 at 10:25 PM, Konstantin Belousov <k...@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
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to