From owner-freebsd-bugs Sat Jan 11 06:50:05 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.4/8.8.4) id GAA19551 for bugs-outgoing; Sat, 11 Jan 1997 06:50:05 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.8.4/8.8.4) id GAA19536; Sat, 11 Jan 1997 06:50:02 -0800 (PST) Resent-Date: Sat, 11 Jan 1997 06:50:02 -0800 (PST) Resent-Message-Id: <199701111450.GAA19536@freefall.freebsd.org> Resent-From: gnats (GNATS Management) Resent-To: freebsd-bugs Resent-Reply-To: FreeBSD-gnats@freefall.FreeBSD.org, Received:(from nobody@localhost) by.freefall.freebsd.org.id.GAA19356;Sat; (8.8.4/8.8.4);, 11 Jan 1997 06:43:44.-0800 (PST) Message-Id: <199701111443.GAA19356@freefall.freebsd.org> Date: Sat, 11 Jan 1997 06:43:44 -0800 (PST) From: tsingle@sunland.gsfc.nasa.gov To: freebsd-gnats-submit@freebsd.org X-Send-Pr-Version: www-1.0 Subject: bin/2448: semctl() not portable -- freebsd requires 4th arg; Solaris, HPUX, etc. don't. Sender: owner-bugs@freebsd.org X-Loop: FreeBSD.org Precedence: bulk >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 #include #include #include 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: