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