Back to index

glibc  2.9
gai_misc.h
Go to the documentation of this file.
00001 /* Copyright (C) 2001, 2006 Free Software Foundation, Inc.
00002    This file is part of the GNU C Library.
00003    Contributed by Ulrich Drepper <drepper@redhat.com>, 2001.
00004 
00005    The GNU C Library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Lesser General Public
00007    License as published by the Free Software Foundation; either
00008    version 2.1 of the License, or (at your option) any later version.
00009 
00010    The GNU C Library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Lesser General Public License for more details.
00014 
00015    You should have received a copy of the GNU Lesser General Public
00016    License along with the GNU C Library; if not, write to the Free
00017    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00018    02111-1307 USA.  */
00019 
00020 #ifndef _GAI_MISC_H
00021 #define _GAI_MISC_H  1
00022 
00023 #include <netdb.h>
00024 #include <signal.h>
00025 
00026 
00027 /* Used to synchronize.  */
00028 struct waitlist
00029   {
00030     struct waitlist *next;
00031 
00032 #ifndef DONT_NEED_GAI_MISC_COND
00033     pthread_cond_t *cond;
00034 #endif
00035     volatile int *counterp;
00036     /* The next field is used in asynchronous `lio_listio' operations.  */
00037     struct sigevent *sigevp;
00038     /* XXX See requestlist, it's used to work around the broken signal
00039        handling in Linux.  */
00040     pid_t caller_pid;
00041   };
00042 
00043 
00044 /* Used to queue requests..  */
00045 struct requestlist
00046   {
00047     int running;
00048 
00049     struct requestlist *next;
00050 
00051     /* Pointer to the actual data.  */
00052     struct gaicb *gaicbp;
00053 
00054     /* List of waiting processes.  */
00055     struct waitlist *waiting;
00056   };
00057 
00058 /* To customize the implementation one can use the following struct.
00059    This implementation follows the one in Irix.  */
00060 struct gaiinit
00061   {
00062     int gai_threads;        /* Maximal number of threads.  */
00063     int gai_num;            /* Number of expected simultanious requests. */
00064     int gai_locks;          /* Not used.  */
00065     int gai_usedba;         /* Not used.  */
00066     int gai_debug;          /* Not used.  */
00067     int gai_numusers;              /* Not used.  */
00068     int gai_idle_time;             /* Number of seconds before idle thread
00069                                terminates.  */
00070     int gai_reserved;
00071   };
00072 
00073 
00074 /* Lock for global I/O list of requests.  */
00075 extern pthread_mutex_t __gai_requests_mutex;
00076 
00077 
00078 /* Enqueue request.  */
00079 extern struct requestlist *__gai_enqueue_request (struct gaicb *gaicbp)
00080      internal_function;
00081 
00082 /* Find request on wait list.  */
00083 extern struct requestlist *__gai_find_request (const struct gaicb *gaicbp)
00084      internal_function;
00085 
00086 /* Remove request from waitlist.  */
00087 extern int __gai_remove_request (struct gaicb *gaicbp)
00088      internal_function;
00089 
00090 /* Notify initiator of request and tell this everybody listening.  */
00091 extern void __gai_notify (struct requestlist *req)
00092      internal_function;
00093 
00094 /* Notify initiator of request.  */
00095 extern int __gai_notify_only (struct sigevent *sigev, pid_t caller_pid)
00096      internal_function;
00097 
00098 /* Send the signal.  */
00099 extern int __gai_sigqueue (int sig, const union sigval val, pid_t caller_pid)
00100      internal_function;
00101 
00102 #endif /* gai_misc.h */