I don't know when but in the last 5 or so releases
sigemptyset(), has become broken.
It probably breaks sigfillset also.
I've included a sample program, and it appears
in /usr/include/asm/signal.h that a sigset_t
is no longer a single long, and when -O2 (__OPTIMIZE__)
is defined /usr/include/signal.h attempts to define
sigemptyset to be an assignment of a long.
from /usr/include/asm/signal.h:
typedef struct {
unsigned long sig[_NSIG_WORDS];
} sigset_t;
from /usr/include/signal.h
...
#define __sigemptyset(set) ((*(set) = 0L), 0)
...
#ifdef __OPTIMIZE__
#define sigemptyset __sigemptyset
...
gcc -O -c sa.c
sa.c: In function `foo':
sa.c:6: incompatible types in assignment
$ cat -n sa.c
1 #include <signal.h>
2
3 void foo(void)
4 {
5 struct sigaction act;
6 sigemptyset(&act.sa_mask);
7 }
$ gcc -E -O -c sa.c | g sa.mask
old_sigset_t sa_mask;
sigset_t sa_mask;
((*( &act.sa_mask ) = 0L), 0) ;
$ gcc -E -O -c sa.c | g -2 sigset_t | head -7
typedef unsigned long old_sigset_t;
typedef struct {
unsigned long sig[(64 / 32 ) ];
} sigset_t;
My workaround was to disable the optimizations
in /usr/include/signal.h
Perhaps sigset_t could be change to a long long
or something that is easier to assign 0 to?