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