svn commit: r210451 - head/sys/sys

Kostik Belousov kostikbel at gmail.com
Sun Jul 25 18:13:00 UTC 2010


On Mon, Jul 26, 2010 at 01:36:07AM +1000, Bruce Evans wrote:
> On Sat, 24 Jul 2010, Stefan Farfeleder wrote:
> 
> >declaring enums like this is not standard C code (seems to be a GCC
> >extension). I don't think we should use this feature in our headers.
> 
> This is unfortunate.  This is because the size of an enum variable
> depends on its complete declaration.  This is an error unconditionaly
> with TenDRA.  It takes -pedantic to get a warning from gcc.
I looked at the C99, and indeed, there is an explicit sentence
"A type specifier of the form enum identifier without an enumerator list
shall only appear after the type it specifies is complete."

I fully agree with Bruce that this is unfortunate, or rather, makes
enum tag declaration completely unuseful. gcc extension greatly simplifies
dealing with the headers pollution.

On the other hand, I disagree with the statement that the size of the
enum variable depends on the full declaration. It seems that C99
defines values of the enum to by of type int, and both i386 and
amd64 ABIs define enums as represented by 4-byte integers.
Yes, I am aware that C++ allows the enum to be assigned the
the shortest arithmetic type that can represent all enum values.

Overall, I will revert both this revision and similar part of the 
r210431, using #include <sys/uio.h> :(.
> 
> >>Modified: head/sys/sys/imgact.h
> >>==============================================================================
> >>--- head/sys/sys/imgact.h	Sat Jul 24 18:05:10 2010	(r210450)
> >>+++ head/sys/sys/imgact.h	Sat Jul 24 18:14:34 2010	(r210451)
> >>@@ -32,8 +32,6 @@
> >> #ifndef _SYS_IMGACT_H_
> >> #define	_SYS_IMGACT_H_
> >>
> >>-#include <sys/uio.h>
> >>-
> 
> The rule that new pollution may not be added to old headers should have
> prevented the need for this removal.
> 
> >> #define MAXSHELLCMDLEN	PAGE_SIZE
> >>
> >> struct image_args {
> >>@@ -75,6 +73,7 @@ struct image_params {
> >> #ifdef _KERNEL
> >> struct sysentvec;
> >> struct thread;
> >>+enum uio_seg;
> >>
> >> #define IMGACT_CORE_COMPRESS	0x01
> 
> Bruce
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/svn-src-head/attachments/20100725/3b9f80e8/attachment.pgp


More information about the svn-src-head mailing list