delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2001/11/26/15:37:45

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: <3C02A7F2.8020209@ece.gatech.edu>
Date: Mon, 26 Nov 2001 15:37:06 -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: Marcello <piteko AT yahoo DOT com>
CC: cygwin AT cygwin DOT com
Subject: Re: sem.h, incompatible tipe for argument 4 of `semctl'
References: <20011126194434 DOT 22446 DOT qmail AT web11603 DOT mail DOT yahoo DOT com>

This is a bug in cygipc:

http://cygwin.com/ml/cygwin/2001-10/msg00955.html
http://cygwin.com/ml/cygwin/2001-10/msg00961.html

Unfortunately, I haven't had a chance to fix it yet.  In your case, 
Marcello, just remove the definition for semun from 
/usr/local/include/sys/sem.h.  SUSv2 says that semun should be defined 
by the application, and not by the system headers (ipc.h & friends).

--Chuck

Marcello wrote:

> Hi,
> I'm tring to use semaphores and I'm working with the patch named
> 'cygipc' found at the 'ported software' page at the cygin website.
> I found an example on the net that seemed to me very easy. 
> 
> The problem is that I get the error:
> semabinit.c:49: incompatible type for argument 4 of `semctl'
> corresponding to the code line:
> if( semctl(id, 0, SETVAL, argument) < 0)
> 
> I found on the net some hints to solve this problem, but they couldn't
> help me. Can you?
> I also attach the code.
> Thank you,
> 
> Marcello
> 
> 
> ------------------------------------------------------------------
> Unix semaphore example
> /* semabinit.c - initialize a semaphore for use by programs sema and
> semb */
> 
> #include <sys/types.h>
> #include <sys/ipc.h>
> #include <sys/sem.h>
> #include <stdio.h>
> 
> #define KEY (1492)
> 
> void main()
> {
>    int id; /* Number by which the semaphore is known within a program
> */
> 
> union semun {
> int val;
> struct semid_ds *buf;
> ushort * array;
> } argument;
> 
>    argument.val = 0;
> 
>    /* Create the semaphore with external key KEY if it doesn't already 
>       exists. Give permissions to the world. */
> 
>    id = semget(KEY, 1, 0666 | IPC_CREAT);
> 
>    /* Always check system returns. */
> 
>    if(id < 0)
>    {
>       fprintf(stderr, "Unable to obtain semaphore. ");
>       exit(0);
>    }
> 
>    /* What we actually get is an array of semaphores. The second 
>       argument to semget() was the array dimension - in our case
>       1. */
> 
>    /* Set the value of the number 0 semaphore in semaphore array
>       # id to the value 0. */
> 
>    if( semctl(id, 0, SETVAL, argument) < 0)
>    {
>       fprintf( stderr, "Cannot set semaphore value. ");
>    }
>    else
>    {
>       fprintf(stderr, "Semaphore %d initialized. ", KEY);
>    }
> }
> 
> 
> =====
> c:\>ptk
> 
> 
> 
> 
> __________________________________________________
> 
> __________________________________________________
> Do You Yahoo!?
> Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month.
> http://geocities.yahoo.com/ps/info1
> 
> --
> 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/
> 
> 



--
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