Subject: kern/19135: sys/shm.h SHMLBA definition unusable.
To: None <gnats-bugs@gnats.netbsd.org>
From: None <cgd@netbsd.org>
List: netbsd-bugs
Date: 11/22/2002 13:46:51
>Number:         19135
>Category:       kern
>Synopsis:       sys/shm.h SHMLBA definition unusable.
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Nov 22 13:47:00 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     Chris Demetriou
>Release:        -current as of 2002-11-22 00:00 UTC
>Organization:
>Environment:
NetBSD/sbmips using NetBSD-current as of date above.
>Description:
<sys/shm.h> provides a useless definition of SHMLBA.

documentation (e.g. shmat(2)) indicates that SHMLBA is
defined by sys/shm.h.  Some code even tries to use it with
only that and a few other irrelevant headers.  One example
is a version of perl i happen to have here (looks like 5.005.03).

Unfortunately, SHMLBA is defined in terms of a sysconf call,
all well and good but _SC_PAGESIZE, used in that call, is not defined.
Obviously the need to prototype sysconf() at that point was understood,
why _SC_PAGESIZE was not also defined there I do not know.
>How-To-Repeat:
% cat foo.c
#include <stdio.h>
#include <sys/shm.h>

main() { printf("%ld\n", (long)SHMLBA);
}
% gcc foo.c
foo.c: In function `main':
foo.c:4: `_SC_PAGESIZE' undeclared (first use in this function)
foo.c:4: (Each undeclared identifier is reported only once
foo.c:4: for each function it appears in.)

>Fix:
#define _SC_PAGESIZE in sys/shm.h?  include the header
(<sys/unistd.h>) from sys/shm.h?

The latter is what solaris does, but I don't know if that's safe
standards-wise w/ our sys/unistd.h.

Note: it looks like this is also an issue in 1.6-branch.
>Release-Note:
>Audit-Trail:
>Unformatted: