poll.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. /* Compatibility definitions for System V `poll' interface.
  17. Copyright (C) 1994-2026 Free Software Foundation, Inc.
  18. This file is part of the GNU C Library.
  19. The GNU C Library is free software; you can redistribute it and/or
  20. modify it under the terms of the GNU Lesser General Public
  21. License as published by the Free Software Foundation; either
  22. version 2.1 of the License, or (at your option) any later version.
  23. The GNU C Library is distributed in the hope that it will be useful,
  24. but WITHOUT ANY WARRANTY; without even the implied warranty of
  25. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  26. Lesser General Public License for more details.
  27. You should have received a copy of the GNU Lesser General Public
  28. License along with the GNU C Library; if not, see
  29. <https://www.gnu.org/licenses/>. */
  30. #ifndef _SYS_POLL_H
  31. #define _SYS_POLL_H 1
  32. #include <features.h>
  33. /* Get the platform dependent bits of `poll'. */
  34. #include <bits/poll.h>
  35. #ifdef __USE_GNU
  36. # include <bits/types/__sigset_t.h>
  37. # include <bits/types/struct_timespec.h>
  38. #endif
  39. /* Type used for the number of file descriptors. */
  40. typedef unsigned long int nfds_t;
  41. /* Data structure describing a polling request. */
  42. struct pollfd
  43. {
  44. int fd; /* File descriptor to poll. */
  45. short int events; /* Types of events poller cares about. */
  46. short int revents; /* Types of events that actually occurred. */
  47. };
  48. __BEGIN_DECLS
  49. /* Poll the file descriptors described by the NFDS structures starting at
  50. FDS. If TIMEOUT is nonzero and not -1, allow TIMEOUT milliseconds for
  51. an event to occur; if TIMEOUT is -1, block until an event occurs.
  52. Returns the number of file descriptors with events, zero if timed out,
  53. or -1 for errors.
  54. This function is a cancellation point and therefore not marked with
  55. __THROW. */
  56. extern int poll (struct pollfd *__fds, nfds_t __nfds, int __timeout)
  57. __fortified_attr_access (__write_only__, 1, 2);
  58. #ifdef __USE_GNU
  59. /* Like poll, but before waiting the threads signal mask is replaced
  60. with that specified in the fourth parameter. For better usability,
  61. the timeout value is specified using a TIMESPEC object.
  62. This function is a cancellation point and therefore not marked with
  63. __THROW. */
  64. extern int ppoll (struct pollfd *__fds, nfds_t __nfds,
  65. const struct timespec *__timeout,
  66. const __sigset_t *__ss)
  67. __fortified_attr_access (__write_only__, 1, 2);
  68. # ifdef __USE_TIME64_REDIRECTS
  69. # ifdef __REDIRECT
  70. extern int __REDIRECT (ppoll, (struct pollfd *__fds, nfds_t __nfds,
  71. const struct timespec *__timeout,
  72. const __sigset_t *__ss),
  73. __ppoll64)
  74. __fortified_attr_access (__write_only__, 1, 2);
  75. # else
  76. # define ppoll __ppoll64
  77. # endif
  78. # endif
  79. #endif
  80. __END_DECLS
  81. /* Define some inlines helping to catch common problems. */
  82. #if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function
  83. # include <bits/poll2.h>
  84. #endif
  85. #endif /* sys/poll.h */