timer_getoverr.c 2.3 KB

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