linux: Add HWCAP2_HBC from Linux 6.6 to AArch64 bits/hwcap.h
[glibc.git] / rt / tst-timer-sigmask.c
bloba6c6d5377827a13383f5bdf5eb02480fba3c0c43
1 /* Check resulting signal mask from POSIX timer using SIGEV_THREAD.
2 Copyright (C) 2020-2023 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
19 #include <stdio.h>
20 #include <time.h>
21 #include <signal.h>
22 #include <stdbool.h>
24 #include <support/check.h>
25 #include <support/test-driver.h>
26 #include <support/xthread.h>
28 #include <internal-signals.h>
30 static pthread_barrier_t barrier;
32 static void
33 thread_handler (union sigval sv)
35 sigset_t ss;
36 sigprocmask (SIG_BLOCK, NULL, &ss);
37 if (test_verbose > 0)
38 printf ("%s: blocked signal mask = { ", __func__);
39 for (int sig = 1; sig < NSIG; sig++)
41 /* POSIX timers threads created to handle SIGEV_THREAD block all
42 signals except SIGKILL, SIGSTOP and glibc internals ones. */
43 if (sigismember (&ss, sig))
45 TEST_VERIFY (sig != SIGKILL && sig != SIGSTOP);
46 TEST_VERIFY (!is_internal_signal (sig));
48 if (test_verbose && sigismember (&ss, sig))
49 printf ("%d, ", sig);
51 if (test_verbose > 0)
52 printf ("}\n");
54 xpthread_barrier_wait (&barrier);
57 static int
58 do_test (void)
60 struct sigevent sev = { 0 };
61 sev.sigev_notify = SIGEV_THREAD;
62 sev.sigev_notify_function = &thread_handler;
64 timer_t timerid;
65 TEST_COMPARE (timer_create (CLOCK_REALTIME, &sev, &timerid), 0);
67 xpthread_barrier_init (&barrier, NULL, 2);
69 struct itimerspec trigger = { 0 };
70 trigger.it_value.tv_nsec = 1000000;
71 TEST_COMPARE (timer_settime (timerid, 0, &trigger, NULL), 0);
73 xpthread_barrier_wait (&barrier);
75 return 0;
78 #include <support/test-driver.c>