timer_settime.c 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /* Copyright (C) 2003 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public License as
  6. published by the Free Software Foundation; either version 2.1 of the
  7. License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; see the file COPYING.LIB. If not,
  14. write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  15. Boston, MA 02111-1307, USA. */
  16. #include <errno.h>
  17. #include <stdlib.h>
  18. #include <time.h>
  19. #include <sysdep.h>
  20. #include <bits/kernel-features.h>
  21. #include "kernel-posix-timers.h"
  22. #ifdef __NR_timer_settime
  23. # ifndef __ASSUME_POSIX_TIMERS
  24. static int compat_timer_settime (timer_t timerid, int flags,
  25. const struct itimerspec *value,
  26. struct itimerspec *ovalue);
  27. # define timer_settime static compat_timer_settime
  28. # include <nptl/sysdeps/pthread/timer_settime.c>
  29. # undef timer_settime
  30. # endif
  31. # ifdef timer_settime_alias
  32. # define timer_settime timer_settime_alias
  33. # endif
  34. int
  35. timer_settime (
  36. timer_t timerid,
  37. int flags,
  38. const struct itimerspec *value,
  39. struct itimerspec *ovalue)
  40. {
  41. # undef timer_settime
  42. # ifndef __ASSUME_POSIX_TIMERS
  43. if (__no_posix_timers >= 0)
  44. # endif
  45. {
  46. struct timer *kt = (struct timer *) timerid;
  47. /* Delete the kernel timer object. */
  48. int res = INLINE_SYSCALL (timer_settime, 4, kt->ktimerid, flags,
  49. value, ovalue);
  50. # ifndef __ASSUME_POSIX_TIMERS
  51. if (res != -1 || errno != ENOSYS)
  52. {
  53. /* We know the syscall support is available. */
  54. __no_posix_timers = 1;
  55. # endif
  56. return res;
  57. # ifndef __ASSUME_POSIX_TIMERS
  58. }
  59. # endif
  60. # ifndef __ASSUME_POSIX_TIMERS
  61. __no_posix_timers = -1;
  62. # endif
  63. }
  64. # ifndef __ASSUME_POSIX_TIMERS
  65. return compat_timer_settime (timerid, flags, value, ovalue);
  66. # endif
  67. }
  68. #else
  69. # ifdef timer_settime_alias
  70. # define timer_settime timer_settime_alias
  71. # endif
  72. /* The new system calls are not available. Use the userlevel
  73. implementation. */
  74. # include <nptl/sysdeps/pthread/timer_settime.c>
  75. #endif