1 /* Check if the thread created by POSIX timer using SIGEV_THREAD is
3 Copyright (C) 2020-2023 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <https://www.gnu.org/licenses/>. */
26 #include <support/check.h>
27 #include <support/test-driver.h>
28 #include <support/xthread.h>
30 static pthread_barrier_t barrier
;
31 static pthread_t timer_thread
;
36 xpthread_barrier_wait (&barrier
);
40 thread_handler (union sigval sv
)
42 timer_thread
= pthread_self ();
44 xpthread_barrier_wait (&barrier
);
46 pthread_cleanup_push (cl
, NULL
);
48 clock_nanosleep (CLOCK_REALTIME
, 0, &(struct timespec
) { 1, 0 }, NULL
);
49 pthread_cleanup_pop (0);
55 struct sigevent sev
= { 0 };
56 sev
.sigev_notify
= SIGEV_THREAD
;
57 sev
.sigev_notify_function
= &thread_handler
;
60 TEST_COMPARE (timer_create (CLOCK_REALTIME
, &sev
, &timerid
), 0);
62 xpthread_barrier_init (&barrier
, NULL
, 2);
64 struct itimerspec trigger
= { 0 };
65 trigger
.it_value
.tv_nsec
= 1000000;
66 TEST_COMPARE (timer_settime (timerid
, 0, &trigger
, NULL
), 0);
68 xpthread_barrier_wait (&barrier
);
70 xpthread_cancel (timer_thread
);
72 xpthread_barrier_wait (&barrier
);
77 /* A stall in cancellation is a regression. */
78 #include <support/test-driver.c>