| 1 | /* Copyright (C) 2003-2020 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 | 
| 17 |    not, see <https://www.gnu.org/licenses/>.  */ | 
| 18 |  | 
| 19 | #include <pthread.h> | 
| 20 | #include <setjmp.h> | 
| 21 | #include <signal.h> | 
| 22 | #include <sys/types.h> | 
| 23 |  | 
| 24 |  | 
| 25 | /* Nonzero if the system calls are not available.  */ | 
| 26 | extern int __no_posix_timers attribute_hidden; | 
| 27 |  | 
| 28 | /* Callback to start helper thread.  */ | 
| 29 | extern void __start_helper_thread (void) attribute_hidden; | 
| 30 |  | 
| 31 | /* Control variable for helper thread creation.  */ | 
| 32 | extern pthread_once_t __helper_once attribute_hidden; | 
| 33 |  | 
| 34 | /* TID of the helper thread.  */ | 
| 35 | extern pid_t __helper_tid attribute_hidden; | 
| 36 |  | 
| 37 | /* List of active SIGEV_THREAD timers.  */ | 
| 38 | extern struct timer *__active_timer_sigev_thread attribute_hidden; | 
| 39 | /* Lock for the __active_timer_sigev_thread.  */ | 
| 40 | extern pthread_mutex_t __active_timer_sigev_thread_lock attribute_hidden; | 
| 41 |  | 
| 42 |  | 
| 43 | /* Type of timers in the kernel.  */ | 
| 44 | typedef int kernel_timer_t; | 
| 45 |  | 
| 46 |  | 
| 47 | /* Internal representation of timer.  */ | 
| 48 | struct timer | 
| 49 | { | 
| 50 |   /* Notification mechanism.  */ | 
| 51 |   int sigev_notify; | 
| 52 |  | 
| 53 |   /* Timer ID returned by the kernel.  */ | 
| 54 |   kernel_timer_t ktimerid; | 
| 55 |  | 
| 56 |   /* All new elements must be added after ktimerid.  And if the thrfunc | 
| 57 |      element is not the third element anymore the memory allocation in | 
| 58 |      timer_create needs to be changed.  */ | 
| 59 |  | 
| 60 |   /* Parameters for the thread to be started for SIGEV_THREAD.  */ | 
| 61 |   void (*thrfunc) (sigval_t); | 
| 62 |   sigval_t sival; | 
| 63 |   pthread_attr_t attr; | 
| 64 |  | 
| 65 |   /* Next element in list of active SIGEV_THREAD timers.  */ | 
| 66 |   struct timer *next; | 
| 67 | }; | 
| 68 |  |