Back to index

glibc  2.9
tst-sigset.c
Go to the documentation of this file.
00001 /* Test sig*set functions.  */
00002 
00003 #include <signal.h>
00004 #include <stdio.h>
00005 
00006 #define TEST_FUNCTION do_test ()
00007 static int
00008 do_test (void)
00009 {
00010   int result = 0;
00011   int sig = -1;
00012 
00013 #define TRY(call)                                                    \
00014   if (call)                                                          \
00015     {                                                                \
00016       printf ("%s (sig = %d): %m\n", #call, sig);                           \
00017       result = 1;                                                    \
00018     }                                                                \
00019   else
00020 
00021 
00022   sigset_t set;
00023   TRY (sigemptyset (&set) != 0);
00024 
00025 #ifdef SIGRTMAX
00026   int max_sig = SIGRTMAX;
00027 #else
00028   int max_sig = NSIG - 1;
00029 #endif
00030 
00031   for (sig = 1; sig <= max_sig; ++sig)
00032     {
00033       TRY (sigismember (&set, sig) != 0);
00034       TRY (sigaddset (&set, sig) != 0);
00035       TRY (sigismember (&set, sig) == 0);
00036       TRY (sigdelset (&set, sig) != 0);
00037       TRY (sigismember (&set, sig) != 0);
00038     }
00039 
00040   return result;
00041 }
00042 
00043 #include "../test-skeleton.c"