]>
Commit | Line | Data |
---|---|---|
08734ccd | 1 | /* Handle real-time signal allocation. Generic version. |
d614a753 | 2 | Copyright (C) 1997-2020 Free Software Foundation, Inc. |
b6ab06ce UD |
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 | |
59ba27a6 | 17 | License along with the GNU C Library; if not, see |
5a82c748 | 18 | <https://www.gnu.org/licenses/>. */ |
b6ab06ce UD |
19 | |
20 | #include <signal.h> | |
21 | ||
08734ccd RM |
22 | /* Another sysdeps file can #define this and then #include this file. */ |
23 | #ifndef RESERVED_SIGRT | |
24 | # define RESERVED_SIGRT 0 | |
25 | #endif | |
26 | ||
b6ab06ce UD |
27 | /* In these variables we keep track of the used variables. If the |
28 | platform does not support any real-time signals we will define the | |
29 | values to some unreasonable value which will signal failing of all | |
30 | the functions below. */ | |
08734ccd RM |
31 | #ifdef __SIGRTMIN |
32 | static int current_rtmin = __SIGRTMIN + RESERVED_SIGRT; | |
33 | static int current_rtmax = __SIGRTMAX; | |
b6ab06ce UD |
34 | #endif |
35 | ||
36 | /* Return number of available real-time signal with highest priority. */ | |
37 | int | |
38 | __libc_current_sigrtmin (void) | |
39 | { | |
40 | #ifdef __SIGRTMIN | |
b6ab06ce | 41 | return current_rtmin; |
08734ccd RM |
42 | #else |
43 | return -1; | |
44 | #endif | |
b6ab06ce UD |
45 | } |
46 | libc_hidden_def (__libc_current_sigrtmin) | |
08734ccd | 47 | strong_alias (__libc_current_sigrtmin, __libc_current_sigrtmin_private) |
b6ab06ce UD |
48 | |
49 | /* Return number of available real-time signal with lowest priority. */ | |
50 | int | |
51 | __libc_current_sigrtmax (void) | |
52 | { | |
53 | #ifdef __SIGRTMIN | |
b6ab06ce | 54 | return current_rtmax; |
08734ccd RM |
55 | #else |
56 | return -1; | |
57 | #endif | |
b6ab06ce UD |
58 | } |
59 | libc_hidden_def (__libc_current_sigrtmax) | |
08734ccd | 60 | strong_alias (__libc_current_sigrtmax, __libc_current_sigrtmax_private) |
b6ab06ce UD |
61 | |
62 | /* Allocate real-time signal with highest/lowest available | |
63 | priority. Please note that we don't use a lock since we assume | |
64 | this function to be called at program start. */ | |
65 | int | |
66 | __libc_allocate_rtsig (int high) | |
67 | { | |
68 | #ifndef __SIGRTMIN | |
69 | return -1; | |
70 | #else | |
b6ab06ce | 71 | if (current_rtmin == -1 || current_rtmin > current_rtmax) |
08734ccd | 72 | /* We don't have any more signals available. */ |
b6ab06ce UD |
73 | return -1; |
74 | ||
75 | return high ? current_rtmin++ : current_rtmax--; | |
76 | #endif | |
77 | } | |
08734ccd | 78 | strong_alias (__libc_allocate_rtsig, __libc_allocate_rtsig_private) |