]> git.ipfire.org Git - thirdparty/glibc.git/blame - nptl/sysdeps/unix/sysv/linux/timer_routines.c
Don't declare __timer_helper_thread. Declare __start_helper_thread, __helper_once...
[thirdparty/glibc.git] / nptl / sysdeps / unix / sysv / linux / timer_routines.c
CommitLineData
09402f5b
UD
1/* Copyright (C) 2003 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
4
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 License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
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.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; see the file COPYING.LIB. If not,
17 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. */
19
20#include <setjmp.h>
21#include <signal.h>
22#include <stdbool.h>
23#include <sysdep.h>
24#include <kernel-features.h>
25#include "kernel-posix-timers.h"
26
27
28#ifdef __NR_timer_create
29/* Helper thread to call the user-provided function. */
30static void *
31timer_sigev_thread (void *arg)
32{
33 struct timer *tk = (struct timer *) arg;
34
35 /* Call the user-provided function. */
36 tk->thrfunc (tk->sival);
37
38 return NULL;
39}
40
41
42/* Helper function to support starting threads for SIGEV_THREAD. */
43void *
44attribute_hidden
45__timer_helper_thread (void *arg)
46{
47 /* Block all signals. */
48 sigset_t ss;
49
50 sigfillset (&ss);
51 (void) pthread_sigmask (SIG_BLOCK, &ss, NULL);
52
53 struct timer *tk = (struct timer *) arg;
54
55 /* Synchronize with the parent. */
56 (void) pthread_barrier_wait (&tk->bar);
57
58 /* We will only wait for the signal the kernel will send. */
59 sigemptyset (&ss);
60 sigaddset (&ss, TIMER_SIG);
61
62 /* Endless loop of waiting for signals. The loop is only ended when
63 the thread is canceled. */
64 while (1)
65 {
66 siginfo_t si;
67
68 if (sigwaitinfo (&ss, &si) > 0 && si.si_timerid == tk->ktimerid)
69 {
70 /* That the signal we are waiting for. */
71 pthread_t th;
72 (void) pthread_create (&th, &tk->attr, timer_sigev_thread, arg);
73 }
74 }
75}
76
77#endif
78
79#ifndef __ASSUME_POSIX_TIMERS
80# include <nptl/sysdeps/pthread/timer_routines.c>
81#endif