lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 | /* Test sig*set functions. */ |
| 2 | |
| 3 | #include <signal.h> |
| 4 | #include <stdio.h> |
| 5 | |
| 6 | #define TEST_FUNCTION do_test () |
| 7 | static int |
| 8 | do_test (void) |
| 9 | { |
| 10 | int result = 0; |
| 11 | int sig = -1; |
| 12 | |
| 13 | #define TRY(call) \ |
| 14 | if (call) \ |
| 15 | { \ |
| 16 | printf ("%s (sig = %d): %m\n", #call, sig); \ |
| 17 | result = 1; \ |
| 18 | } \ |
| 19 | else |
| 20 | |
| 21 | |
| 22 | sigset_t set; |
| 23 | TRY (sigemptyset (&set) != 0); |
| 24 | |
| 25 | #ifdef SIGRTMAX |
| 26 | int max_sig = SIGRTMAX; |
| 27 | #else |
| 28 | int max_sig = NSIG - 1; |
| 29 | #endif |
| 30 | |
| 31 | for (sig = 1; sig <= max_sig; ++sig) |
| 32 | { |
| 33 | TRY (sigismember (&set, sig) != 0); |
| 34 | TRY (sigaddset (&set, sig) != 0); |
| 35 | TRY (sigismember (&set, sig) == 0); |
| 36 | TRY (sigdelset (&set, sig) != 0); |
| 37 | TRY (sigismember (&set, sig) != 0); |
| 38 | } |
| 39 | |
| 40 | return result; |
| 41 | } |
| 42 | |
| 43 | #include "../test-skeleton.c" |