F
Franklin Li
Hi All,
In Richard's book AUEP, one example as below.
But I compile with gcc in Soalris 9. It will report error.
gcc -I/usr/include -I/opt/exp/include -I/opt/exp/gnu/include -Wall -Dsun -c
setops.c
setops.c: In function `sigaddset':
setops.c:12: error: invalid operands to binary |
*** Error code 1
make: Fatal error: Command failed for target `setops.o'
Could you tell me the reason and how to fix it.
Thanks.
Franklin
***********************************************************
#define SIGBAD(signo) ((signo) <= 0 || (signo) >= NSIG)
/* <signal.h> usually defines NSIG to include signal number 0 */
int
sigaddset(sigset_t *set, int signo)
{
if (SIGBAD(signo)) { errno = EINVAL; return(-1); }
*set |= (1 << (signo - 1)); /* turn bit on */
return(0);
}
int
sigdelset(sigset_t *set, int signo)
{
if (SIGBAD(signo)) { errno = EINVAL; return(-1); }
*set &= ~(1 << (signo - 1)); /* turn bit off */
return(0);
}
int
sigismember(const sigset_t *set, int signo)
{
if (SIGBAD(signo)) { errno = EINVAL; return(-1); }
return( (*set & (1 << (signo - 1))) != 0 );
return(0);
}
**********************************************************
In Richard's book AUEP, one example as below.
But I compile with gcc in Soalris 9. It will report error.
gcc -I/usr/include -I/opt/exp/include -I/opt/exp/gnu/include -Wall -Dsun -c
setops.c
setops.c: In function `sigaddset':
setops.c:12: error: invalid operands to binary |
*** Error code 1
make: Fatal error: Command failed for target `setops.o'
Could you tell me the reason and how to fix it.
Thanks.
Franklin
***********************************************************
#define SIGBAD(signo) ((signo) <= 0 || (signo) >= NSIG)
/* <signal.h> usually defines NSIG to include signal number 0 */
int
sigaddset(sigset_t *set, int signo)
{
if (SIGBAD(signo)) { errno = EINVAL; return(-1); }
*set |= (1 << (signo - 1)); /* turn bit on */
return(0);
}
int
sigdelset(sigset_t *set, int signo)
{
if (SIGBAD(signo)) { errno = EINVAL; return(-1); }
*set &= ~(1 << (signo - 1)); /* turn bit off */
return(0);
}
int
sigismember(const sigset_t *set, int signo)
{
if (SIGBAD(signo)) { errno = EINVAL; return(-1); }
return( (*set & (1 << (signo - 1))) != 0 );
return(0);
}
**********************************************************