delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2001/11/27/00:41:17

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT sources DOT redhat DOT com
Delivered-To: mailing list cygwin AT sources DOT redhat DOT com
Message-ID: <3C032753.2000708@ece.gatech.edu>
Date: Tue, 27 Nov 2001 00:40:35 -0500
From: Charles Wilson <cwilson AT ece DOT gatech DOT edu>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:0.9.4) Gecko/20011019 Netscape6/6.2
X-Accept-Language: en-us
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: [ANN][RFC] cygipc-1.11 at cygutils

I've updated cygipc to version 1.11.  You can download it from:
http://www.neuro.gatech.edu/users/cwilson/cygutils/index.html

The main changes here are:
   1) remove definition of 'union semun' from sem.h
   2) changed signature of semctl():
      OLD  int semctl(int, int, int, union semun)
      NEW  int semctl(int, int, int, ...)
   These changes are according to the SUSv2 spec:
   http://www.opengroup.org/onlinepubs/007908799/xsh/semctl.html

   And were necessary to address these concerns:
   http://cygwin.com/ml/cygwin/2001-10/msg00955.html
   http://cygwin.com/ml/cygwin/2001-10/msg00961.html
   http://cygwin.com/ml/cygwin/2001-11/msg01586.html
   http://cygwin.com/ml/cygwin/2001-11/msg01589.html

However, Linux *DOESN'T* do it that way.  Linux DOES define 'union 
semun' in sem.h.  Linux REQUIRES all four arguments to semctl.

So, did I do the right thing?  Should I try to match SUSv2 or Linux? 
Also, I have some concerns about passing a union as a variable arg...can 
you really DO that?  I mean, it compiles and all, and SEEMS to work, but...

Questions:

1)  postgresql folks: does this work for you?

2)  should I go back to Linux style (define union semun in sem.h, 
require four args on semctl())

I'm even a bit confused by the SUSv2 spec: it says that client code MUST 
define union semun -- and then SPECIFIES exactly how it should be 
defined.  Why leave it up to the client code, if there's no freedom? 
Just do it in the header!  What am I missing?  (Obviouly Linux agrees 
with me, but...)

3)  is this code below okay (the whole vararg union thing...)?
      (I parse the va_arg list INSIDE the switch (cmd), because the 
fourth arg is only required to be there for certain cmd's, and va_* 
behavior is indeterminate when you 'run out' of actual varargs.)

--Chuck

int semctl (int semid, int semnum, int cmd, ... )
{
	struct semid_ds *buf = NULL;
	struct semid_ds tbuf;
	union semun arg;
	int val;
	int i, id;
	struct semid_ds *sma;
	struct ipc_perm *ipcp;
	unsigned int nsems;
	ushort *array = NULL;
	char LBuff[100] ;
	HANDLE LHandle ;
	long LPrevious ;
	va_list ap;

....

	switch (cmd) {
	case IPC_INFO:
	case SEM_INFO:
	{
	   struct seminfo * tmp;
	   struct seminfo seminfo;
	   va_start(ap, cmd);
	   arg = va_arg(ap, union semun);
	   tmp = arg.__buf;
	   va_end(ap);

...     (use 'tmp')

	}


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019