gai_misc.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /* Copyright (C) 2001-2019 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. Contributed by Ulrich Drepper <drepper@redhat.com>, 2001.
  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
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the 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; if not, see
  14. <http://www.gnu.org/licenses/>. */
  15. #ifndef _GAI_MISC_H
  16. #define _GAI_MISC_H 1
  17. #include <netdb.h>
  18. #include <signal.h>
  19. /* Used to synchronize. */
  20. struct waitlist
  21. {
  22. struct waitlist *next;
  23. #ifndef DONT_NEED_GAI_MISC_COND
  24. pthread_cond_t *cond;
  25. #endif
  26. volatile unsigned int *counterp;
  27. /* The next field is used in asynchronous `lio_listio' operations. */
  28. struct sigevent *sigevp;
  29. /* XXX See requestlist, it's used to work around the broken signal
  30. handling in Linux. */
  31. pid_t caller_pid;
  32. };
  33. /* Used to queue requests.. */
  34. struct requestlist
  35. {
  36. int running;
  37. struct requestlist *next;
  38. /* Pointer to the actual data. */
  39. struct gaicb *gaicbp;
  40. /* List of waiting processes. */
  41. struct waitlist *waiting;
  42. };
  43. /* To customize the implementation one can use the following struct.
  44. This implementation follows the one in Irix. */
  45. struct gaiinit
  46. {
  47. int gai_threads; /* Maximal number of threads. */
  48. int gai_num; /* Number of expected simultanious requests. */
  49. int gai_locks; /* Not used. */
  50. int gai_usedba; /* Not used. */
  51. int gai_debug; /* Not used. */
  52. int gai_numusers; /* Not used. */
  53. int gai_idle_time; /* Number of seconds before idle thread
  54. terminates. */
  55. int gai_reserved;
  56. };
  57. /* Lock for global I/O list of requests. */
  58. extern pthread_mutex_t __gai_requests_mutex;
  59. /* Enqueue request. */
  60. extern struct requestlist *__gai_enqueue_request (struct gaicb *gaicbp)
  61. attribute_hidden;
  62. /* Find request on wait list. */
  63. extern struct requestlist *__gai_find_request (const struct gaicb *gaicbp)
  64. attribute_hidden;
  65. /* Remove request from waitlist. */
  66. extern int __gai_remove_request (struct gaicb *gaicbp)
  67. attribute_hidden;
  68. /* Notify initiator of request and tell this everybody listening. */
  69. extern void __gai_notify (struct requestlist *req)
  70. attribute_hidden;
  71. /* Notify initiator of request. */
  72. extern int __gai_notify_only (struct sigevent *sigev, pid_t caller_pid)
  73. attribute_hidden;
  74. /* Send the signal. */
  75. extern int __gai_sigqueue (int sig, const union sigval val, pid_t caller_pid);
  76. #endif /* gai_misc.h */