timer_getoverr.c 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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
  14. not, see <http://www.gnu.org/licenses/>. */
  15. #include <errno.h>
  16. #include <time.h>
  17. #include <sysdep.h>
  18. #include <bits/kernel-features.h>
  19. #include "kernel-posix-timers.h"
  20. #ifdef __NR_timer_getoverrun
  21. # ifndef __ASSUME_POSIX_TIMERS
  22. static int compat_timer_getoverrun (timer_t timerid);
  23. # define timer_getoverrun static compat_timer_getoverrun
  24. # include <nptl/sysdeps/pthread/timer_getoverr.c>
  25. # undef timer_getoverrun
  26. # endif
  27. # ifdef timer_getoverrun_alias
  28. # define timer_getoverrun timer_getoverrun_alias
  29. # endif
  30. int
  31. timer_getoverrun (
  32. timer_t timerid)
  33. {
  34. # undef timer_getoverrun
  35. # ifndef __ASSUME_POSIX_TIMERS
  36. if (__no_posix_timers >= 0)
  37. # endif
  38. {
  39. struct timer *kt = (struct timer *) timerid;
  40. /* Get the information from the kernel. */
  41. int res = INLINE_SYSCALL (timer_getoverrun, 1, kt->ktimerid);
  42. # ifndef __ASSUME_POSIX_TIMERS
  43. if (res != -1 || errno != ENOSYS)
  44. {
  45. /* We know the syscall support is available. */
  46. __no_posix_timers = 1;
  47. # endif
  48. return res;
  49. # ifndef __ASSUME_POSIX_TIMERS
  50. }
  51. # endif
  52. # ifndef __ASSUME_POSIX_TIMERS
  53. __no_posix_timers = -1;
  54. # endif
  55. }
  56. # ifndef __ASSUME_POSIX_TIMERS
  57. return compat_timer_getoverrun (timerid);
  58. # endif
  59. }
  60. #else
  61. # ifdef timer_getoverrun_alias
  62. # define timer_getoverrun timer_getoverrun_alias
  63. # endif
  64. /* The new system calls are not available. Use the userlevel
  65. implementation. */
  66. # include <nptl/sysdeps/pthread/timer_getoverr.c>
  67. #endif