allocrtsig.c 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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, write to the Free
  15. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  16. 02111-1307 USA. */
  17. #include <features.h>
  18. #include <signal.h>
  19. #include <sys/syscall.h>
  20. /* Only enable rt signals when it is supported at compile time */
  21. #ifndef __NR_rt_sigaction
  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. */
  26. static int current_rtmin = -1;
  27. static int current_rtmax = -1;
  28. #else
  29. # ifdef __UCLIBC_HAS_THREADS_NATIVE__
  30. static int current_rtmin = __SIGRTMIN + 2;
  31. # elif defined __UCLIBC_HAS_THREADS__ && !defined __LINUXTHREADS_OLD__
  32. /* psm: might be good for LT old as well, do not want to break it for now */
  33. /* Sanity check */
  34. # if !defined __SIGRTMIN || (__SIGRTMAX - __SIGRTMIN) < 3
  35. # error "This must not happen"
  36. # endif
  37. static int current_rtmin = __SIGRTMIN + 3;
  38. # else
  39. static int current_rtmin = __SIGRTMIN;
  40. # endif
  41. static int current_rtmax = __SIGRTMAX;
  42. #endif
  43. /* Return number of available real-time signal with highest priority. */
  44. int __libc_current_sigrtmin (void)
  45. {
  46. return current_rtmin;
  47. }
  48. /* Return number of available real-time signal with lowest priority. */
  49. int __libc_current_sigrtmax (void)
  50. {
  51. return current_rtmax;
  52. }
  53. #if 0
  54. /* Allocate real-time signal with highest/lowest available
  55. priority. Please note that we don't use a lock since we assume
  56. this function to be called at program start. */
  57. int __libc_allocate_rtsig (int high);
  58. int __libc_allocate_rtsig (int high)
  59. {
  60. if (current_rtmin == -1 || current_rtmin > current_rtmax)
  61. /* We don't have anymore signal available. */
  62. return -1;
  63. return high ? current_rtmin++ : current_rtmax--;
  64. }
  65. #endif