timerfd.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. //
  2. // Copyright 2026 Aarav Ravindra Kharade
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. //
  16. /* Copyright (C) 2008-2026 Free Software Foundation, Inc.
  17. This file is part of the GNU C Library.
  18. The GNU C Library is free software; you can redistribute it and/or
  19. modify it under the terms of the GNU Lesser General Public
  20. License as published by the Free Software Foundation; either
  21. version 2.1 of the License, or (at your option) any later version.
  22. The GNU C Library is distributed in the hope that it will be useful,
  23. but WITHOUT ANY WARRANTY; without even the implied warranty of
  24. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  25. Lesser General Public License for more details.
  26. You should have received a copy of the GNU Lesser General Public
  27. License along with the GNU C Library; if not, see
  28. <https://www.gnu.org/licenses/>. */
  29. #ifndef _SYS_TIMERFD_H
  30. #define _SYS_TIMERFD_H 1
  31. #include <time.h>
  32. #include <bits/types/struct_itimerspec.h>
  33. /* Get the platform-dependent flags. */
  34. #include <bits/timerfd.h>
  35. /* Bits to be set in the FLAGS parameter of `timerfd_settime'. */
  36. enum
  37. {
  38. TFD_TIMER_ABSTIME = 1 << 0,
  39. #define TFD_TIMER_ABSTIME TFD_TIMER_ABSTIME
  40. TFD_TIMER_CANCEL_ON_SET = 1 << 1
  41. #define TFD_TIMER_CANCEL_ON_SET TFD_TIMER_CANCEL_ON_SET
  42. };
  43. __BEGIN_DECLS
  44. /* Return file descriptor for new interval timer source. */
  45. extern int timerfd_create (__clockid_t __clock_id, int __flags) __THROW;
  46. /* Set next expiration time of interval timer source UFD to UTMR. If
  47. FLAGS has the TFD_TIMER_ABSTIME flag set the timeout value is
  48. absolute. Optionally return the old expiration time in OTMR. */
  49. extern int timerfd_settime (int __ufd, int __flags,
  50. const struct itimerspec *__utmr,
  51. struct itimerspec *__otmr) __THROW;
  52. #ifdef __USE_TIME64_REDIRECTS
  53. # if defined(__REDIRECT_NTH)
  54. extern int __REDIRECT_NTH (timerfd_settime,
  55. (int __ufd, int __flags,
  56. const struct itimerspec *__restrict __value,
  57. struct itimerspec *__restrict __ovalue),
  58. __timerfd_settime64);
  59. # else
  60. # define timerfd_settime __timerfd_settime64
  61. # endif
  62. #endif
  63. /* Return the next expiration time of UFD. */
  64. extern int timerfd_gettime (int __ufd, struct itimerspec *__otmr) __THROW;
  65. #ifdef __USE_TIME64_REDIRECTS
  66. # if defined(__REDIRECT_NTH)
  67. extern int __REDIRECT_NTH (timerfd_gettime, (int __ufd,
  68. struct itimerspec *__otmr),
  69. __timerfd_gettime64);
  70. # else
  71. # define timerfd_gettime __timerfd_gettime64
  72. # endif
  73. #endif
  74. __END_DECLS
  75. #endif /* sys/timerfd.h */