allocrtsig.c 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /* Handle real-time signal allocation.
  2. Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
  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.
  9. The GNU C Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with the GNU C Library; if not, see
  15. <http://www.gnu.org/licenses/>. */
  16. #include <features.h>
  17. #include <signal.h>
  18. #include <sys/syscall.h>
  19. /* Only enable rt signals when it is supported at compile time */
  20. #ifndef __NR_rt_sigaction
  21. /* In these variables we keep track of the used variables. If the
  22. platform does not support any real-time signals we will define the
  23. values to some unreasonable value which will signal failing of all
  24. the functions below. */
  25. static int current_rtmin = -1;
  26. static int current_rtmax = -1;
  27. #else
  28. # ifdef __UCLIBC_HAS_THREADS_NATIVE__
  29. static int current_rtmin = __SIGRTMIN + 2;
  30. # elif defined __UCLIBC_HAS_THREADS__ && !defined __UCLIBC_HAS_LINUXTHREADS__
  31. /* psm: might be good for LT old as well, do not want to break it for now */
  32. /* Sanity check */
  33. # if !defined __SIGRTMIN || (__SIGRTMAX - __SIGRTMIN) < 3
  34. # error "This must not happen"
  35. # endif
  36. static int current_rtmin = __SIGRTMIN + 3;
  37. # else
  38. static int current_rtmin = __SIGRTMIN;
  39. # endif
  40. static int current_rtmax = __SIGRTMAX;
  41. #endif
  42. /* Return number of available real-time signal with highest priority. */
  43. int __libc_current_sigrtmin (void)
  44. {
  45. return current_rtmin;
  46. }
  47. /* Return number of available real-time signal with lowest priority. */
  48. int __libc_current_sigrtmax (void)
  49. {
  50. return current_rtmax;
  51. }
  52. #if 0
  53. /* Allocate real-time signal with highest/lowest available
  54. priority. Please note that we don't use a lock since we assume
  55. this function to be called at program start. */
  56. int __libc_allocate_rtsig (int high);
  57. int __libc_allocate_rtsig (int high)
  58. {
  59. if (current_rtmin == -1 || current_rtmin > current_rtmax)
  60. /* We don't have anymore signal available. */
  61. return -1;
  62. return high ? current_rtmin++ : current_rtmax--;
  63. }
  64. #endif