gai_misc.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /* Copyright (C) 2001-2026 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. The GNU C Library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Lesser General Public
  5. License as published by the Free Software Foundation; either
  6. version 2.1 of the License, or (at your option) any later version.
  7. The GNU C Library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public
  12. License along with the GNU C Library; if not, see
  13. <https://www.gnu.org/licenses/>. */
  14. #ifndef _GAI_MISC_H
  15. #define _GAI_MISC_H 1
  16. #include <netdb.h>
  17. #include <signal.h>
  18. /* Used to synchronize. */
  19. struct waitlist
  20. {
  21. struct waitlist *next;
  22. #ifndef DONT_NEED_GAI_MISC_COND
  23. pthread_cond_t *cond;
  24. #endif
  25. volatile unsigned int *counterp;
  26. /* The next field is used in asynchronous `lio_listio' operations. */
  27. struct sigevent *sigevp;
  28. /* XXX See requestlist, it's used to work around the broken signal
  29. handling in Linux. */
  30. pid_t caller_pid;
  31. };
  32. /* Used to queue requests.. */
  33. struct requestlist
  34. {
  35. int running;
  36. struct requestlist *next;
  37. /* Pointer to the actual data. */
  38. struct gaicb *gaicbp;
  39. /* List of waiting processes. */
  40. struct waitlist *waiting;
  41. };
  42. /* To customize the implementation one can use the following struct.
  43. This implementation follows the one in Irix. */
  44. struct gaiinit
  45. {
  46. int gai_threads; /* Maximal number of threads. */
  47. int gai_num; /* Number of expected simultaneous requests. */
  48. int gai_locks; /* Not used. */
  49. int gai_usedba; /* Not used. */
  50. int gai_debug; /* Not used. */
  51. int gai_numusers; /* Not used. */
  52. int gai_idle_time; /* Number of seconds before idle thread
  53. terminates. */
  54. int gai_reserved;
  55. };
  56. /* Lock for global I/O list of requests. */
  57. extern pthread_mutex_t __gai_requests_mutex;
  58. /* Enqueue request. */
  59. extern struct requestlist *__gai_enqueue_request (struct gaicb *gaicbp)
  60. attribute_hidden;
  61. /* Find request on wait list. */
  62. extern struct requestlist *__gai_find_request (const struct gaicb *gaicbp)
  63. attribute_hidden;
  64. /* Remove request from waitlist. */
  65. extern int __gai_remove_request (struct gaicb *gaicbp)
  66. attribute_hidden;
  67. /* Notify initiator of request and tell this everybody listening. */
  68. extern void __gai_notify (struct requestlist *req)
  69. attribute_hidden;
  70. /* Notify initiator of request. */
  71. extern int __gai_notify_only (struct sigevent *sigev, pid_t caller_pid)
  72. attribute_hidden;
  73. /* Send the signal. */
  74. extern int __gai_sigqueue (int sig, const union sigval val, pid_t caller_pid);
  75. libc_hidden_proto (__gai_sigqueue)
  76. #endif /* gai_misc.h */