Re: kern/104436: [PATCH] sys/sem.h should include sys/types.h

From: Cheng-Lung Sung <clsung_at_FreeBSD.org>
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:
> > 
> > > System: FreeBSD.csie.nctu.edu.tw 6.1-STABLE FreeBSD 6.1-STABLE #9: Thu May 
> 11 14:31:45 CST 2006     
> root_at_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

    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)

-- 
Cheng-Lung Sung - clsung_at_
Received on Tue Oct 17 2006 - 00:13:34 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:01 UTC