]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/uclibc/lib/contrib/uclibc/libpthread/linuxthreads/sysdeps/unix/sysv/linux/allocrtsig.c
update
[l4.git] / l4 / pkg / uclibc / lib / contrib / uclibc / libpthread / linuxthreads / sysdeps / unix / sysv / linux / allocrtsig.c
1 /* Handle real-time signal allocation.
2    Copyright (C) 1997,98,99,2002 Free Software Foundation, Inc.
3    This file is part of the GNU C Library.
4    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
5
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.
10
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.
15
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    <http://www.gnu.org/licenses/>.  */
19
20 #include <signal.h>
21
22 /* Sanity check.  */
23 #if !defined __SIGRTMIN || (__SIGRTMAX - __SIGRTMIN) < 3
24 # error "This must not happen"
25 #endif
26
27 static int current_rtmin;
28 static int current_rtmax;
29
30 static int initialized;
31
32 #include <testrtsig.h>
33
34 static void
35 init (void)
36 {
37   if (!kernel_has_rtsig ())
38     {
39       current_rtmin = -1;
40       current_rtmax = -1;
41     }
42   else
43     {
44       current_rtmin = __SIGRTMIN + 3;
45       current_rtmax = __SIGRTMAX;
46     }
47   initialized = 1;
48 }
49
50 /* Return number of available real-time signal with highest priority.  */
51 int
52 __libc_current_sigrtmin (void)
53 {
54   if (!initialized)
55     init ();
56   return current_rtmin;
57 }
58 strong_alias (__libc_current_sigrtmin, __libc_current_sigrtmin_private)
59 libc_hidden_def (__libc_current_sigrtmin)
60
61 /* Return number of available real-time signal with lowest priority.  */
62 int
63 __libc_current_sigrtmax (void)
64 {
65   if (!initialized)
66     init ();
67   return current_rtmax;
68 }
69 strong_alias (__libc_current_sigrtmax, __libc_current_sigrtmax_private)
70 libc_hidden_def (__libc_current_sigrtmax)
71
72 #if 0
73 /* Allocate real-time signal with highest/lowest available
74    priority.  Please note that we don't use a lock since we assume
75    this function to be called at program start.  */
76 int
77 __libc_allocate_rtsig (int high)
78 {
79   if (!initialized)
80     init ();
81   if (current_rtmin == -1 || current_rtmin > current_rtmax)
82     /* We don't have anymore signal available.  */
83     return -1;
84
85   return high ? current_rtmin++ : current_rtmax--;
86 }
87 strong_alias (__libc_allocate_rtsig, __libc_allocate_rtsig_private)
88 #endif