Mail Archives: cygwin/2001/11/27/00:41:17
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 -