From clsung@FreeBSD.csie.nctu.edu.tw  Sun Oct 15 13:56:40 2006
Return-Path: <clsung@FreeBSD.csie.nctu.edu.tw>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id DA15016A412;
	Sun, 15 Oct 2006 13:56:40 +0000 (UTC)
	(envelope-from clsung@FreeBSD.csie.nctu.edu.tw)
Received: from FreeBSD.csie.nctu.edu.tw (freebsd.csie.nctu.edu.tw [140.113.17.209])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 64B5E43D49;
	Sun, 15 Oct 2006 13:56:40 +0000 (GMT)
	(envelope-from clsung@FreeBSD.csie.nctu.edu.tw)
Received: from localhost (localhost.csie.nctu.edu.tw [127.0.0.1])
	by FreeBSD.csie.nctu.edu.tw (Postfix) with ESMTP id 4F9FA7E908;
	Sun, 15 Oct 2006 21:57:11 +0800 (CST)
Received: from FreeBSD.csie.nctu.edu.tw ([127.0.0.1])
	by localhost (FreeBSD.csie.nctu.edu.tw [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id jJoBqNjAdz1R; Sun, 15 Oct 2006 21:57:10 +0800 (CST)
Received: by FreeBSD.csie.nctu.edu.tw (Postfix, from userid 1038)
	id A28897E98D; Sun, 15 Oct 2006 21:57:10 +0800 (CST)
Message-Id: <20061015135710.A28897E98D@FreeBSD.csie.nctu.edu.tw>
Date: Sun, 15 Oct 2006 21:57:10 +0800 (CST)
From: Cheng-Lung Sung <clsung@FreeBSD.org>
Reply-To: Cheng-Lung Sung <clsung@FreeBSD.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc: freebsd-hackers@freebsd.org, freebsd-current@freebsd.org
Subject: [PATCH] sys/sem.h should include sys/types.h
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         104436
>Category:       kern
>Synopsis:       [PATCH] sys/sem.h should include sys/types.h
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Oct 15 14:00:36 GMT 2006
>Closed-Date:    Mon Nov 20 22:42:48 GMT 2006
>Last-Modified:  Mon Nov 20 22:42:48 GMT 2006
>Originator:     Cheng-Lung Sung
>Release:        FreeBSD 6.1-PRERELEASE i386
>Organization:
FreeBSD @ Taiwan
>Environment:
System: FreeBSD.csie.nctu.edu.tw 6.1-STABLE FreeBSD 6.1-STABLE #9: Thu May 11 14:31:45 CST 2006     root@FreeBSD.csie.nctu.edu.tw:/home/usr.obj/usr/src/sys/FREEBSD  i386

>Description:
- sys/sem.h has included sys/ipc.h, which includes sys/_types.h
  but it (and its including files) does not include sys/types.h
- therefore, in sys/sem.h struct semid_ds declares "time_t sem_otime;" ...etc
- if we only compile a program which do not include sys/types.h, it will fail.
>How-To-Repeat:
test the following program (copy from devel/ruby-sysvipc), named conftest.c:
1: #include <sys/sem.h>
2:
3: /*top*/
4: int
5: main ()
6: {
7: if ((union semun *) 0)
8:   return 0;
9: if (sizeof (union semun))
10:   return 0;
11:   ;
12:   return 0;
13: }

We will got the following result:
In file included from conftest.c:1:
/usr/include/sys/sem.h:21: error: syntax error before "time_t"
/usr/include/sys/sem.h:23: error: syntax error before "time_t"

>Fix:

Index: sys/sys/sem.h
===================================================================
RCS file: /home/ncvs/src/sys/sys/sem.h,v
retrieving revision 1.29
diff -u -r1.29 sem.h
--- sys/sys/sem.h	17 Nov 2004 13:12:06 -0000	1.29
+++ sys/sys/sem.h	15 Oct 2006 13:47:37 -0000
@@ -10,6 +10,7 @@
 #ifndef _SYS_SEM_H_
 #define _SYS_SEM_H_
 
+#include <sys/types.h>
 #include <sys/ipc.h>
 
 struct sem;

>Release-Note:
>Audit-Trail:

From: Bruce Evans <bde@zeta.org.au>
To: Cheng-Lung Sung <clsung@FreeBSD.org>
Cc: FreeBSD-gnats-submit@FreeBSD.org, freebsd-hackers@FreeBSD.org, 
    freebsd-current@FreeBSD.org, freebsd-bugs@FreeBSD.org
Subject: Re: kern/104436: [PATCH] sys/sem.h should include sys/types.h
Date: Mon, 16 Oct 2006 01:21:59 +1000 (EST)

 On Sun, 15 Oct 2006, Cheng-Lung Sung wrote:
 
 > System: FreeBSD.csie.nctu.edu.tw 6.1-STABLE FreeBSD 6.1-STABLE #9: Thu May 11 14:31:45 CST 2006     root@FreeBSD.csie.nctu.edu.tw:/home/usr.obj/usr/src/sys/FREEBSD  i386
 >
 >> Description:
 > - sys/sem.h has included sys/ipc.h, which includes sys/_types.h
 >  but it (and its including files) does not include sys/types.h
 > - therefore, in sys/sem.h struct semid_ds declares "time_t sem_otime;" ...etc
 > - if we only compile a program which do not include sys/types.h, it will fail.
 
 Including sys/types.h would add lots of namespace pollution which
 sys/ipc.h and sys/sem.h are trying hard to avoid.   sem.h is trying too
 hard -- POSIX requires it to declare time_t (and pid_t, key_t and size_t,
 which it already declares).
 
 Bruce

From: Cheng-Lung Sung <clsung@FreeBSD.org>
To: Bruce Evans <bde@zeta.org.au>
Cc: Cheng-Lung Sung <clsung@FreeBSD.org>, freebsd-current@FreeBSD.org,
	freebsd-hackers@FreeBSD.org, freebsd-bugs@FreeBSD.org,
	FreeBSD-gnats-submit@FreeBSD.org
Subject: Re: kern/104436: [PATCH] sys/sem.h should include sys/types.h
Date: Mon, 16 Oct 2006 09:21:31 +0800

 --6TrnltStXW4iwmi0
 Content-Type: text/plain; charset=big5
 Content-Disposition: inline
 Content-Transfer-Encoding: quoted-printable
 
 On Mon, Oct 16, 2006 at 01:21:59AM +1000, Bruce Evans wrote:
 > On Sun, 15 Oct 2006, Cheng-Lung Sung wrote:
 >=20
 > >System: FreeBSD.csie.nctu.edu.tw 6.1-STABLE FreeBSD 6.1-STABLE #9: Thu M=
 ay=20
 > >11 14:31:45 CST 2006    =20
 > >root@FreeBSD.csie.nctu.edu.tw:/home/usr.obj/usr/src/sys/FREEBSD  i386
 > >
 > >>Description:
 > >- sys/sem.h has included sys/ipc.h, which includes sys/_types.h
 > > but it (and its including files) does not include sys/types.h
 > >- therefore, in sys/sem.h struct semid_ds declares "time_t sem_otime;"=
 =20
 > >...etc
 > >- if we only compile a program which do not include sys/types.h, it will=
 =20
 > >fail.
 >=20
 > Including sys/types.h would add lots of namespace pollution which
 > sys/ipc.h and sys/sem.h are trying hard to avoid.   sem.h is trying too
 > hard -- POSIX requires it to declare time_t (and pid_t, key_t and size_t,
 > which it already declares).
 >=20
 > Bruce
 
     You're right, I should try to pass COMMON_HEADERS to ruby-sysipc=20
     instead of polluting namespace.
 
     Thanks,
 
 --=20
 Cheng-Lung Sung - clsung@
 
 --6TrnltStXW4iwmi0
 Content-Type: application/pgp-signature
 Content-Disposition: inline
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.5 (FreeBSD)
 
 iD8DBQFFMt6a+AeJ85Vui8ERAkpiAKCT0qnMLSJa1lUsjqBA7XOpvkKeQgCfc0sn
 r/6xcrfx71DYTCstiZC8GPA=
 =P6zp
 -----END PGP SIGNATURE-----
 
 --6TrnltStXW4iwmi0--

From: John Baldwin <jhb@freebsd.org>
To: freebsd-hackers@freebsd.org
Cc: Bruce Evans <bde@zeta.org.au>, Cheng-Lung Sung <clsung@freebsd.org>,
        freebsd-current@freebsd.org, freebsd-bugs@freebsd.org,
        FreeBSD-gnats-submit@freebsd.org
Subject: Re: kern/104436: [PATCH] sys/sem.h should include sys/types.h
Date: Mon, 16 Oct 2006 14:31:24 -0400

 On Sunday 15 October 2006 11:21, Bruce Evans wrote:
 > On Sun, 15 Oct 2006, Cheng-Lung Sung wrote:
 > 
 > > System: FreeBSD.csie.nctu.edu.tw 6.1-STABLE FreeBSD 6.1-STABLE #9: Thu May 
 11 14:31:45 CST 2006     
 root@FreeBSD.csie.nctu.edu.tw:/home/usr.obj/usr/src/sys/FREEBSD  i386
 > >
 > >> Description:
 > > - sys/sem.h has included sys/ipc.h, which includes sys/_types.h
 > >  but it (and its including files) does not include sys/types.h
 > > - therefore, in sys/sem.h struct semid_ds declares "time_t 
 sem_otime;" ...etc
 > > - if we only compile a program which do not include sys/types.h, it will 
 fail.
 > 
 > Including sys/types.h would add lots of namespace pollution which
 > sys/ipc.h and sys/sem.h are trying hard to avoid.   sem.h is trying too
 > hard -- POSIX requires it to declare time_t (and pid_t, key_t and size_t,
 > which it already declares).
 
 Is this better?
 
 Index: sem.h
 ===================================================================
 RCS file: /usr/cvs/src/sys/sys/sem.h,v
 retrieving revision 1.29
 diff -c -r1.29 sem.h
 *** sem.h	17 Nov 2004 13:12:06 -0000	1.29
 --- sem.h	16 Oct 2006 18:30:05 -0000
 ***************
 *** 111,116 ****
 --- 111,121 ----
   #define _SIZE_T_DECLARED
   #endif
   
 + #ifndef _TIME_T_DECLARED
 + typedef	__time_t	time_t;
 + #define	_TIME_T_DECLARED
 + #endif
 + 
   #ifndef _PID_T_DECLARED
   typedef __pid_t         pid_t;
   #define _PID_T_DECLARED
 
 (it looks like pid_t should be before size_t in sem.h btw)
 
 -- 
 John Baldwin

From: Bruce Evans <bde@zeta.org.au>
To: John Baldwin <jhb@freebsd.org>
Cc: freebsd-hackers@freebsd.org, Cheng-Lung Sung <clsung@freebsd.org>, 
    freebsd-current@freebsd.org, freebsd-bugs@freebsd.org, 
    FreeBSD-gnats-submit@freebsd.org
Subject: Re: kern/104436: [PATCH] sys/sem.h should include sys/types.h
Date: Tue, 17 Oct 2006 11:39:09 +1000 (EST)

 [This is still being sent to too many mailing lists since I don't know
   which ones it should go to except gnats.]
 
 On Mon, 16 Oct 2006, John Baldwin wrote:
 
 >> Including sys/types.h would add lots of namespace pollution which
 >> sys/ipc.h and sys/sem.h are trying hard to avoid.   sem.h is trying too
 >> hard -- POSIX requires it to declare time_t (and pid_t, key_t and size_t,
 >> which it already declares).
 >
 > Is this better?
 >
 > Index: sem.h
 > ===================================================================
 > RCS file: /usr/cvs/src/sys/sys/sem.h,v
 > retrieving revision 1.29
 > diff -c -r1.29 sem.h
 > *** sem.h	17 Nov 2004 13:12:06 -0000	1.29
 > --- sem.h	16 Oct 2006 18:30:05 -0000
 > ***************
 > *** 111,116 ****
 > --- 111,121 ----
 >  #define _SIZE_T_DECLARED
 >  #endif
 >
 > + #ifndef _TIME_T_DECLARED
 > + typedef	__time_t	time_t;
 > + #define	_TIME_T_DECLARED
 > + #endif
 > +
 >  #ifndef _PID_T_DECLARED
 >  typedef __pid_t         pid_t;
 >  #define _PID_T_DECLARED
 >
 > (it looks like pid_t should be before size_t in sem.h btw)
 
 Good.  (I didn't check if there are any other missing typedefs.)
 Please commit.
 
 The old typedefs also have non-KNF whitespace.  sys/ipc.h is better.
 
 Bruce

From: Cheng-Lung Sung <clsung@FreeBSD.org>
To: John Baldwin <jhb@freebsd.org>
Cc: freebsd-hackers@freebsd.org, Bruce Evans <bde@zeta.org.au>,
	Cheng-Lung Sung <clsung@freebsd.org>, freebsd-current@freebsd.org,
	freebsd-bugs@freebsd.org, FreeBSD-gnats-submit@freebsd.org
Subject: Re: kern/104436: [PATCH] sys/sem.h should include sys/types.h
Date: Tue, 17 Oct 2006 10:14:07 +0800

 On Mon, Oct 16, 2006 at 02:31:24PM -0400, John Baldwin wrote:
 > On Sunday 15 October 2006 11:21, Bruce Evans wrote:
 > > On Sun, 15 Oct 2006, Cheng-Lung Sung wrote:
 > >=20
 > > > System: FreeBSD.csie.nctu.edu.tw 6.1-STABLE FreeBSD 6.1-STABLE #9: Th=
 u May=20
 > 11 14:31:45 CST 2006    =20
 > root@FreeBSD.csie.nctu.edu.tw:/home/usr.obj/usr/src/sys/FREEBSD  i386
 > > >
 > > >> Description:
 > > > - sys/sem.h has included sys/ipc.h, which includes sys/_types.h
 > > >  but it (and its including files) does not include sys/types.h
 > > > - therefore, in sys/sem.h struct semid_ds declares "time_t=20
 > sem_otime;" ...etc
 > > > - if we only compile a program which do not include sys/types.h, it w=
 ill=20
 > fail.
 > >=20
 > > Including sys/types.h would add lots of namespace pollution which
 > > sys/ipc.h and sys/sem.h are trying hard to avoid.   sem.h is trying too
 > > hard -- POSIX requires it to declare time_t (and pid_t, key_t and size_=
 t,
 > > which it already declares).
 >=20
 > Is this better?
 >=20
 > Index: sem.h
 > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
 > RCS file: /usr/cvs/src/sys/sys/sem.h,v
 > retrieving revision 1.29
 > diff -c -r1.29 sem.h
 > *** sem.h	17 Nov 2004 13:12:06 -0000	1.29
 > --- sem.h	16 Oct 2006 18:30:05 -0000
 > ***************
 > *** 111,116 ****
 > --- 111,121 ----
 >   #define _SIZE_T_DECLARED
 >   #endif
 >  =20
 > + #ifndef _TIME_T_DECLARED
 > + typedef	__time_t	time_t;
 > + #define	_TIME_T_DECLARED
 > + #endif
 > +=20
 >   #ifndef _PID_T_DECLARED
 >   typedef __pid_t         pid_t;
 >   #define _PID_T_DECLARED
 >=20
 > (it looks like pid_t should be before size_t in sem.h btw)
 >=20
 > --=20
 > John Baldwin
 
     Thanks, I didn't go through the whole sem.h.
     Also, it seems we should put these parts before 'sturct semid_ds'.=20
     or say, after we include sys/ipc.h (which include sys/_types.h)
 
 --=20
 Cheng-Lung Sung - clsung@

From: Bruce Evans <bde@zeta.org.au>
To: Cheng-Lung Sung <clsung@freebsd.org>
Cc: John Baldwin <jhb@freebsd.org>, freebsd-hackers@freebsd.org, 
    freebsd-current@freebsd.org, freebsd-bugs@freebsd.org, 
    FreeBSD-gnats-submit@freebsd.org
Subject: Re: kern/104436: [PATCH] sys/sem.h should include sys/types.h
Date: Tue, 17 Oct 2006 12:41:04 +1000 (EST)

 On Tue, 17 Oct 2006, Cheng-Lung Sung wrote:
 
 > On Mon, Oct 16, 2006 at 02:31:24PM -0400, John Baldwin wrote:
 >> Is this better?
 >> ...
 >    Thanks, I didn't go through the whole sem.h.
 >    Also, it seems we should put these parts before 'sturct semid_ds'.
 >    or say, after we include sys/ipc.h (which include sys/_types.h)
 
 Yes, that is especially needed for time_t, since it is the only one of
 the typedef'ed types used early in sys/sem.h.  The others might be needed
 later when the non-typedefed types are cleaned up.  (sys/ipc.h needs
 cleaning up more.  It still spells uid_t as "unsigned short", but uids
 aren't that short...)
 
 Bruce

From: John Baldwin <jhb@freebsd.org>
To: Bruce Evans <bde@zeta.org.au>
Cc: Cheng-Lung Sung <clsung@freebsd.org>, FreeBSD-gnats-submit@freebsd.org
Subject: Re: kern/104436: [PATCH] sys/sem.h should include sys/types.h
Date: Tue, 17 Oct 2006 13:43:22 -0400

 On Monday 16 October 2006 22:41, Bruce Evans wrote:
 > On Tue, 17 Oct 2006, Cheng-Lung Sung wrote:
 > 
 > > On Mon, Oct 16, 2006 at 02:31:24PM -0400, John Baldwin wrote:
 > >> Is this better?
 > >> ...
 > >    Thanks, I didn't go through the whole sem.h.
 > >    Also, it seems we should put these parts before 'sturct semid_ds'.
 > >    or say, after we include sys/ipc.h (which include sys/_types.h)
 > 
 > Yes, that is especially needed for time_t, since it is the only one of
 > the typedef'ed types used early in sys/sem.h.  The others might be needed
 > later when the non-typedefed types are cleaned up.  (sys/ipc.h needs
 > cleaning up more.  It still spells uid_t as "unsigned short", but uids
 > aren't that short...)
 
 I know Robert wants to fix that, but hasn't due to the ABI breakage that
 would ensue.
 
 How's this, it removes extra includes of cdefs.h and _types.h (ipc.h
 already includes them), moves the typedefs earlier and includes them
 in the _KERNEL case (consistent with ipc.h) and fixes the whitespace
 in the typedefs.
 
 Index: sem.h
 ===================================================================
 RCS file: /usr/cvs/src/sys/sys/sem.h,v
 retrieving revision 1.29
 diff -u -r1.29 sem.h
 --- sem.h	17 Nov 2004 13:12:06 -0000	1.29
 +++ sem.h	17 Oct 2006 17:41:20 -0000
 @@ -12,6 +12,21 @@
  
  #include <sys/ipc.h>
  
 +#ifndef _PID_T_DECLARED
 +typedef	__pid_t		pid_t;
 +#define	_PID_T_DECLARED
 +#endif
 +
 +#ifndef _SIZE_T_DECLARED
 +typedef	__size_t	size_t;
 +#define	_SIZE_T_DECLARED
 +#endif
 +
 +#ifndef _TIME_T_DECLARED
 +typedef	__time_t	time_t;
 +#define	_TIME_T_DECLARED
 +#endif
 +
  struct sem;
  
  struct semid_ds {
 @@ -100,21 +115,8 @@
   * Process sem_undo vectors at proc exit.
   */
  void	semexit(struct proc *p);
 -#endif /* _KERNEL */
  
 -#ifndef _KERNEL
 -#include <sys/cdefs.h>
 -#include <sys/_types.h>
 -
 -#ifndef _SIZE_T_DECLARED
 -typedef __size_t        size_t;
 -#define _SIZE_T_DECLARED
 -#endif
 -
 -#ifndef _PID_T_DECLARED
 -typedef __pid_t         pid_t;
 -#define _PID_T_DECLARED
 -#endif
 +#else /* ! _KERNEL */
  
  __BEGIN_DECLS
  int semsys(int, ...);
 @@ -122,6 +124,7 @@
  int semget(key_t, int, int);
  int semop(int, struct sembuf *, size_t);
  __END_DECLS
 +
  #endif /* !_KERNEL */
  
  #endif /* !_SYS_SEM_H_ */
 
 -- 
 John Baldwin

From: Cheng-Lung Sung <clsung@FreeBSD.org>
To: John Baldwin <jhb@freebsd.org>
Cc: Bruce Evans <bde@zeta.org.au>, Cheng-Lung Sung <clsung@freebsd.org>,
	FreeBSD-gnats-submit@freebsd.org
Subject: Re: kern/104436: [PATCH] sys/sem.h should include sys/types.h
Date: Wed, 18 Oct 2006 08:05:26 +0800

 --4Ckj6UjgE2iN1+kY
 Content-Type: text/plain; charset=big5
 Content-Disposition: inline
 Content-Transfer-Encoding: quoted-printable
 
 On Tue, Oct 17, 2006 at 01:43:22PM -0400, John Baldwin wrote:
 > On Monday 16 October 2006 22:41, Bruce Evans wrote:
 > > On Tue, 17 Oct 2006, Cheng-Lung Sung wrote:
 > > >    Thanks, I didn't go through the whole sem.h.
 > > >    Also, it seems we should put these parts before 'sturct semid_ds'.
 > > >    or say, after we include sys/ipc.h (which include sys/_types.h)
 > > Yes, that is especially needed for time_t, since it is the only one of
 > > the typedef'ed types used early in sys/sem.h.  The others might be need=
 ed
 > > later when the non-typedefed types are cleaned up.  (sys/ipc.h needs
 > > cleaning up more.  It still spells uid_t as "unsigned short", but uids
 > > aren't that short...)
 >=20
 > I know Robert wants to fix that, but hasn't due to the ABI breakage that
 > would ensue.
 >=20
 > How's this, it removes extra includes of cdefs.h and _types.h (ipc.h
 > already includes them), moves the typedefs earlier and includes them
 > in the _KERNEL case (consistent with ipc.h) and fixes the whitespace
 > in the typedefs.
 >=20
 > Index: sem.h
 > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
 > RCS file: /usr/cvs/src/sys/sys/sem.h,v
 > retrieving revision 1.29
 > diff -u -r1.29 sem.h
 > --- sem.h	17 Nov 2004 13:12:06 -0000	1.29
 > +++ sem.h	17 Oct 2006 17:41:20 -0000
 > @@ -12,6 +12,21 @@
 > =20
 >  #include <sys/ipc.h>
 > =20
 > +#ifndef _PID_T_DECLARED
 > +typedef	__pid_t		pid_t;
 > +#define	_PID_T_DECLARED
 > +#endif
 > +
 > +#ifndef _SIZE_T_DECLARED
 > +typedef	__size_t	size_t;
 > +#define	_SIZE_T_DECLARED
 > +#endif
 > +
 > +#ifndef _TIME_T_DECLARED
 > +typedef	__time_t	time_t;
 > +#define	_TIME_T_DECLARED
 > +#endif
 > +
 >  struct sem;
 > =20
 >  struct semid_ds {
 > @@ -100,21 +115,8 @@
 >   * Process sem_undo vectors at proc exit.
 >   */
 >  void	semexit(struct proc *p);
 > -#endif /* _KERNEL */
 > =20
 > -#ifndef _KERNEL
 > -#include <sys/cdefs.h>
 > -#include <sys/_types.h>
 > -
 > -#ifndef _SIZE_T_DECLARED
 > -typedef __size_t        size_t;
 > -#define _SIZE_T_DECLARED
 > -#endif
 > -
 > -#ifndef _PID_T_DECLARED
 > -typedef __pid_t         pid_t;
 > -#define _PID_T_DECLARED
 > -#endif
 > +#else /* ! _KERNEL */
 > =20
 >  __BEGIN_DECLS
 >  int semsys(int, ...);
 > @@ -122,6 +124,7 @@
 >  int semget(key_t, int, int);
 >  int semop(int, struct sembuf *, size_t);
 >  __END_DECLS
 > +
 >  #endif /* !_KERNEL */
 > =20
 >  #endif /* !_SYS_SEM_H_ */
 
 Thanks John, I think this solves my problem.=20
 
 --=20
 Cheng-Lung Sung - clsung@
 
 --4Ckj6UjgE2iN1+kY
 Content-Type: application/pgp-signature
 Content-Disposition: inline
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.5 (FreeBSD)
 
 iD8DBQFFNW/F+AeJ85Vui8ERAhhUAJ4/ETq/x+XKxjYVMAibv/HClQp3UwCeLaBN
 kG5pGQ0yIFe4Y7qaLDR/OVI=
 =uY5g
 -----END PGP SIGNATURE-----
 
 --4Ckj6UjgE2iN1+kY--

From: Bruce Evans <bde@zeta.org.au>
To: John Baldwin <jhb@FreeBSD.org>
Cc: Cheng-Lung Sung <clsung@FreeBSD.org>, FreeBSD-gnats-submit@FreeBSD.org
Subject: Re: kern/104436: [PATCH] sys/sem.h should include sys/types.h
Date: Wed, 18 Oct 2006 10:09:04 +1000 (EST)

 On Tue, 17 Oct 2006, John Baldwin wrote:
 
 > How's this, it removes extra includes of cdefs.h and _types.h (ipc.h
 > already includes them), moves the typedefs earlier and includes them
 > in the _KERNEL case (consistent with ipc.h) and fixes the whitespace
 > in the typedefs.
 
 OK.  POSIX actually requires the namespace pollution with everything in
 sys/ipc.h, so the include of this can't be cleaned up and we may as well
 depend on its internals.
 
 I did a quick review of symbols in sys/sem.h:
 - POSIX seems to overspecify the representation: "A semaphore shall be
    respresented by an anonymous struct containing the following members:"
    [semval, sempid, semncnt, semzcnt]".  FreeBSD doesn't declare any of
    these struct members.
 - FreeBSD declares several things that aren't required by POSIX and uses
    bad names for most of these.  The worst ones are the struct member
    names `val', `buf' and `array'.  POSIX cannot reserve these, and sem.h
    mostly uses a `sem' prefix to avoid such pollution.  These seem to be
    implementation details that don't belong in the header anyway.
 
 I didn't check the symbols imported from sys/ipc.h.  Both of these headers
 are XSI extensions, so they don't need many visibility ifdefs internally.
 
 Bruce

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/104436: commit references a PR
Date: Thu, 19 Oct 2006 14:37:03 +0000 (UTC)

 jhb         2006-10-19 14:36:42 UTC
 
   FreeBSD src repository
 
   Modified files:
     sys/sys              sem.h 
   Log:
   - Define time_t in sys/sem.h so it doesn't require sys/types.h.
   - Move the pid_t, size_t, and time_t definitions earlier in the file, sort
     them, and fix whitespace.
   - Drop redundant includes of sys/cdefs.h and sys/_types.h as sys/ipc.h
     already includes them.
   
   PR:             kern/104436
   Reviewed by:    bde
   Reported by:    clsung
   MFC after:      3 days
   
   Revision  Changes    Path
   1.30      +17 -14    src/sys/sys/sem.h
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 

From: John Baldwin <jhb@freebsd.org>
To: Bruce Evans <bde@zeta.org.au>
Cc: Cheng-Lung Sung <clsung@freebsd.org>, FreeBSD-gnats-submit@freebsd.org
Subject: Re: kern/104436: [PATCH] sys/sem.h should include sys/types.h
Date: Thu, 19 Oct 2006 10:39:59 -0400

 On Tuesday 17 October 2006 20:09, Bruce Evans wrote:
 > On Tue, 17 Oct 2006, John Baldwin wrote:
 > 
 > > How's this, it removes extra includes of cdefs.h and _types.h (ipc.h
 > > already includes them), moves the typedefs earlier and includes them
 > > in the _KERNEL case (consistent with ipc.h) and fixes the whitespace
 > > in the typedefs.
 > 
 > OK.  POSIX actually requires the namespace pollution with everything in
 > sys/ipc.h, so the include of this can't be cleaned up and we may as well
 > depend on its internals.
 
 I've committed it.
 
 > I did a quick review of symbols in sys/sem.h:
 > - POSIX seems to overspecify the representation: "A semaphore shall be
 >    respresented by an anonymous struct containing the following members:"
 >    [semval, sempid, semncnt, semzcnt]".  FreeBSD doesn't declare any of
 >    these struct members.
 
 It does, but 'struct sem' is private to kern/sysv_sem.c:
 
 struct sem {
         u_short semval;         /* semaphore value */
         pid_t   sempid;         /* pid of last operation */
         u_short semncnt;        /* # awaiting semval > cval */
         u_short semzcnt;        /* # awaiting semval = 0 */
 };
 
 > - FreeBSD declares several things that aren't required by POSIX and uses
 >    bad names for most of these.  The worst ones are the struct member
 >    names `val', `buf' and `array'.  POSIX cannot reserve these, and sem.h
 >    mostly uses a `sem' prefix to avoid such pollution.  These seem to be
 >    implementation details that don't belong in the header anyway.
 
 Hmm the 'semun' union is actually passed as an arg to semctl() and the names
 it uses seem to be standard as Linux, etc. use the same name.
 
 > I didn't check the symbols imported from sys/ipc.h.  Both of these headers
 > are XSI extensions, so they don't need many visibility ifdefs internally.
 
 -- 
 John Baldwin

From: Bruce Evans <bde@zeta.org.au>
To: John Baldwin <jhb@FreeBSD.org>
Cc: Cheng-Lung Sung <clsung@FreeBSD.org>, FreeBSD-gnats-submit@FreeBSD.org
Subject: Re: kern/104436: [PATCH] sys/sem.h should include sys/types.h
Date: Fri, 20 Oct 2006 09:54:11 +1000 (EST)

 On Thu, 19 Oct 2006, John Baldwin wrote:
 
 > On Tuesday 17 October 2006 20:09, Bruce Evans wrote:
 
 >> I did a quick review of symbols in sys/sem.h:
 >> - POSIX seems to overspecify the representation: "A semaphore shall be
 >>    respresented by an anonymous struct containing the following members:"
 >>    [semval, sempid, semncnt, semzcnt]".  FreeBSD doesn't declare any of
 >>    these struct members.
 >
 > It does, but 'struct sem' is private to kern/sysv_sem.c:
 >
 > struct sem {
 >        u_short semval;         /* semaphore value */
 >        pid_t   sempid;         /* pid of last operation */
 >        u_short semncnt;        /* # awaiting semval > cval */
 >        u_short semzcnt;        /* # awaiting semval = 0 */
 > };
 
 This is kernel-only (but only has semval and sempid) in Linux-2.6.10
 too, so its visibility in FreeBSD seems to be OK.
 
 >> - FreeBSD declares several things that aren't required by POSIX and uses
 >>    bad names for most of these.  The worst ones are the struct member
 >>    names `val', `buf' and `array'.  POSIX cannot reserve these, and sem.h
 >>    mostly uses a `sem' prefix to avoid such pollution.  These seem to be
 >>    implementation details that don't belong in the header anyway.
 >
 > Hmm the 'semun' union is actually passed as an arg to semctl() and the names
 > it uses seem to be standard as Linux, etc. use the same name.
 
 It is actually in POSIX, but at least in the old 2001 draft 7 that I
 looked at, it is only described under semctl() and is not mentioned under
 sem.h.
 
 Bruce
State-Changed-From-To: open->closed 
State-Changed-By: jhb 
State-Changed-When: Mon Nov 20 22:40:29 UTC 2006 
State-Changed-Why:  
Fix merged to RELENG_6. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=104436 
>Unformatted:
