volatile registers

Brian Matthews blm at cxsea.UUCP
Sat Jan 7 03:14:38 AEST 1989


The Beach Bum (jfh at rpp386.Dallas.TX.US) writes:
|A common usage is in interrupt [ software ] handlers where the
|signal catching routine sets a flag and returns.
|
|The proper definition for such a flag should be
|
|in catch.c:
|--
|int	sigflag;
|
|int	catch (sig)
|{
|	...
|	sigflag = 1;
|	...
|}
|--
|then outside catch.c you must use
|
|extern	volatile int sigflag;

The spirit of the posting is correct, but there are a couple of technical
errors.

First, the type of sigflag should be sig_atomic_t, not int.  Second, as
the function argument to signal is void (*fn)(int), catch should be a
void function.  See the signal handling section of the draft (section
4.7, I believe).

-- 
Brian L. Matthews  blm at cxsea.UUCP   ...{mnetor,uw-beaver!ssc-vax}!cxsea!blm
+1 206 251 6811    Computer X Inc. - a division of Motorola New Enterprises



More information about the Comp.std.c mailing list