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

Bruce Evans bde at zeta.org.au
Thu Oct 19 17:00:47 PDT 2006


The following reply was made to PR kern/104436; it has been noted by GNATS.

From: Bruce Evans <bde at zeta.org.au>
To: John Baldwin <jhb at FreeBSD.org>
Cc: Cheng-Lung Sung <clsung at FreeBSD.org>, FreeBSD-gnats-submit at 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


More information about the freebsd-bugs mailing list