[mercury-users] problem with signals

Fergus Henderson fjh at cs.mu.OZ.AU
Fri Mar 7 01:04:05 AEDT 2003


On 05-Mar-2003, pieter.laeremans at student.kuleuven.ac.be wrote:
> 
> I envisaged a second approach, namely to block the SIGIO signal while
> I'm processing the data.  I tested this on a prototype c-only
> program.  That works fine however when I wanted to do exactly the same
> in mercury by including signal.h and using statements such as this :
> 
> :- pragma foreign_proc("C", wait_for_data(Data::out, IO0::di,IO::uo), [promise_pure], "
> 		      sem_wait(sem);
> 		      sigemptyset(&blockset);
> 		      sigaddset(&blockset, SIGIO);
> 		      sigprocmask(SIG_BLOCK, &blockset, NULL); 		      
> 		      IO = IO0;
> 		      Data = (MR_String) buffer;
> ").
> 
> 
> The mercury compiler issued the following errors :
> 
> legolibrary.m:174: warning: implicit declaration of function `sigemptyset'
> legolibrary.m:175: warning: implicit declaration of function `sigaddset'
> legolibrary.m:176: warning: implicit declaration of function `sigprocmask'
> legolibrary.m:176: `SIG_BLOCK' undeclared (first use in this function)

Those error messages are coming from the C compiler, actually,
not the Mercury compiler.

> Does anyone has an explanation for this ?

By default, the Mercury compiler will invoke the C compiler with
`-ansi', which will give you an ANSI/ISO C compliant set of standard
header files.  In standard ISO C, the <signal.h> header file does not
provide sigemptyset() etc.  If you want to make use of Posix extensions,
such as sigemptyset() etc., you need to use the `--no-ansi-c' option to
mmc and/or the `--no-ansi' option to mgnuc.

This mess is needed because Posix chose to standardize the same header
names as ANSI/ISO C, but with different contents.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-users mailing list
post:  mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the users mailing list