Re: svn commit: r243134 - head/sys/sys

2012-11-16 Thread mdf
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.

Does the forward declaration prevent another warning?

Thanks,
matthew

   Reported and reviewed by: bde
   MFC after:28 days

 Modified:
   head/sys/sys/syscallsubr.h

 Modified: head/sys/sys/syscallsubr.h
 ==
 --- head/sys/sys/syscallsubr.h  Fri Nov 16 06:22:14 2012(r243133)
 +++ head/sys/sys/syscallsubr.h  Fri Nov 16 06:25:20 2012(r243134)
 @@ -35,25 +35,26 @@
  #include sys/mount.h

  struct file;
 +enum idtype;
  struct itimerval;
  struct image_args;
  struct jail;
 +struct kevent;
 +struct kevent_copyops;
 +struct kld_file_stat;
 +struct ksiginfo;
  struct mbuf;
  struct msghdr;
  struct msqid_ds;
 +struct ogetdirentries_args;
  struct rlimit;
  struct rusage;
 -struct __wrusage;
  union semun;
 +struct sendfile_args;
  struct sockaddr;
  struct stat;
 -struct kevent;
 -struct kevent_copyops;
 -struct kld_file_stat;
 -struct ksiginfo;
 -struct sendfile_args;
  struct thr_param;
 -struct ogetdirentries_args;
 +struct __wrusage;

  intkern___getcwd(struct thread *td, u_char *buf, enum uio_seg bufseg,
 u_int buflen);
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


Re: svn commit: r243134 - head/sys/sys

2012-11-16 Thread Konstantin Belousov
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.
 
 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.


pgpG7hmjYsrfQ.pgp
Description: PGP signature


Re: svn commit: r243134 - head/sys/sys

2012-11-16 Thread Bruce Evans

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-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


Re: svn commit: r243134 - head/sys/sys

2012-11-16 Thread Konstantin Belousov
On Sat, Nov 17, 2012 at 04:24:06AM +1100, Bruce Evans wrote:
 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.
In my copy of the SVID rev 4, document abi386, it is stated absolutely
clear that Integral enum types are represented as the signed word with
sizeof 4 and alignment 4. This is in Figure 3-1 Scalar Types, page 28.

For amd64, in the ABI document  0.99.6, enums are again specified in the
figure 3.1 as having signed fourbyte representation with the alighnment 4.
Now, there is a footnote stating
C++ and some implementations of C permit enums larger than an int. The
underlying type is bumped to an unsigned int, long int or unsigned long
int, in that order. 

But I think that the complain is not about the ABI, but regarding the
use of the extension.

I see three routes forward:
- Keep the things as is. The only downside is the use of the extension which
  is supported by both gcc and clang.
- Change idtype_t to int and use #defines to introduce P_XXX constants.
  This is not easy since Solaris contrib code uses enum, and enum was
  selected to not introduce unneeded incompatibility, at least for the
  kernel code.
- Include sys/wait.h from sys/syscallsubr.h. A modification is to put
  idtype_h into a private header and include the header from syscallsubr.h
  and wait.h.

My preference is to keep the things as is, but I am open for discussion.
 
 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


pgpaip4cWcBcS.pgp
Description: PGP signature


svn commit: r243134 - head/sys/sys

2012-11-15 Thread Konstantin Belousov
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.
  
  Reported and reviewed by: bde
  MFC after:28 days

Modified:
  head/sys/sys/syscallsubr.h

Modified: head/sys/sys/syscallsubr.h
==
--- head/sys/sys/syscallsubr.h  Fri Nov 16 06:22:14 2012(r243133)
+++ head/sys/sys/syscallsubr.h  Fri Nov 16 06:25:20 2012(r243134)
@@ -35,25 +35,26 @@
 #include sys/mount.h
 
 struct file;
+enum idtype;
 struct itimerval;
 struct image_args;
 struct jail;
+struct kevent;
+struct kevent_copyops;
+struct kld_file_stat;
+struct ksiginfo;
 struct mbuf;
 struct msghdr;
 struct msqid_ds;
+struct ogetdirentries_args;
 struct rlimit;
 struct rusage;
-struct __wrusage;
 union semun;
+struct sendfile_args;
 struct sockaddr;
 struct stat;
-struct kevent;
-struct kevent_copyops;
-struct kld_file_stat;
-struct ksiginfo;
-struct sendfile_args;
 struct thr_param;
-struct ogetdirentries_args;
+struct __wrusage;
 
 intkern___getcwd(struct thread *td, u_char *buf, enum uio_seg bufseg,
u_int buflen);
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org