1 /* Handle real-time signal allocation. Generic version.
2 Copyright (C) 1997-2022 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/>. */
20 #include <internal-signals.h>
22 /* In these variables we keep track of the used variables. If the
23 platform does not support any real-time signals we will define the
24 values to some unreasonable value which will signal failing of all
25 the functions below. */
27 static int current_rtmin
= __SIGRTMIN
+ RESERVED_SIGRT
;
28 static int current_rtmax
= __SIGRTMAX
;
31 /* Return number of available real-time signal with highest priority. */
33 __libc_current_sigrtmin (void)
41 libc_hidden_def (__libc_current_sigrtmin
)
43 /* Return number of available real-time signal with lowest priority. */
45 __libc_current_sigrtmax (void)
53 libc_hidden_def (__libc_current_sigrtmax
)
55 /* Allocate real-time signal with highest/lowest available
56 priority. Please note that we don't use a lock since we assume
57 this function to be called at program start. */
59 __libc_allocate_rtsig (int high
)
64 if (current_rtmin
== -1 || current_rtmin
> current_rtmax
)
65 /* We don't have any more signals available. */
68 return high
? current_rtmin
++ : current_rtmax
--;