Date: Sat, 11 Jan 1997 06:43:44 -0800 (PST) From: tsingle@sunland.gsfc.nasa.gov To: freebsd-gnats-submit@freebsd.org Subject: bin/2448: semctl() not portable -- freebsd requires 4th arg; Solaris, HPUX, etc. don't. Message-ID: <199701111443.GAA19356@freefall.freebsd.org> Resent-Message-ID: <199701111450.GAA19536@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 2448
>Category: bin
>Synopsis: semctl() not portable -- freebsd requires 4th arg; Solaris, HPUX, etc. don't.
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: freebsd-bugs
>State: open
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Sat Jan 11 06:50:01 PST 1997
>Last-Modified:
>Originator: Tim Singletary
>Organization:
August Automation, Inc.
>Release: 2.2-961014-SNAP
>Environment:
>Description:
FreeBSD's semctl() requires four arguments; in Solaris, HP-UX, etc.
the fourth argument isn't needed unless the third argument is SETVAL,
GETALL, SETALL, IPC_STAT, or IPC_SET. The SunOS manual
_Porting_Software_to_SPARC_ states:
Programs that call semctl() with these subcommands [those
requiring a fourth argument] must pass the union itself, rather
than an element of the union, or a constant such as 0 (zero).
Programs that call semctl() with other subcommands should omit the
fourth argument, rather than pass a constant such as 0 (zero).
In other words, there's a portability issue: FreeBSD is not compatible
with other unixes.
>How-To-Repeat:
(not applicable)
>Fix:
Here's my suggestion for code patches; I don't have any suggestions on
how to fix the man page.
1) Change line 175(?) of /usr/include/sys/sem.h from
int semctl __P((int, int, int, union semun));
to
int semctl __P((int, int, int, ...));
2) Replace /usr/src/lib/libc/gen/semctl.c with
#include <stdarg.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/sem.h>
int semctl(int semid, int semnum, int cmd, ...)
{
va_list ap;
union semun fourth_arg;
union semun *fourth_arg_ptr;
va_start(ap,cmd);
if (cmd == IPC_SET || cmd == IPC_STAT || cmd == GETALL
|| cmd == SETVAL || cmd == SETALL) {
fourth_arg = va_arg(ap, union semun);
fourth_arg_ptr = &fourth_arg;
} else {
fourth_arg_ptr = NULL;
}
va_end(ap);
return(semsys(0, semid, semnum, cmd, fourth_arg_ptr));
}
>Audit-Trail:
>Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199701111443.GAA19356>
