2.9
[glibc/nacl-glibc.git] / sysdeps / pthread / aio_misc.h
blob50962c751966087d0253c0d6daf84a4d5e26625d
1 /* Copyright (C) 1997,1999,2000,2001,2003,2006 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
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.
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.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, write to the Free
16 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
17 02111-1307 USA. */
19 #ifndef _AIO_MISC_H
20 #define _AIO_MISC_H 1
22 #include <aio.h>
23 #include <pthread.h>
26 /* Extend the operation enum. */
27 enum
29 LIO_DSYNC = LIO_NOP + 1,
30 LIO_SYNC,
31 LIO_READ64 = LIO_READ | 128,
32 LIO_WRITE64 = LIO_WRITE | 128
36 /* Union of the two request types. */
37 typedef union
39 struct aiocb aiocb;
40 struct aiocb64 aiocb64;
41 } aiocb_union;
44 /* Used to synchronize. */
45 struct waitlist
47 struct waitlist *next;
49 /* The next two fields is used in synchronous `lio_listio' operations. */
50 #ifndef DONT_NEED_AIO_MISC_COND
51 pthread_cond_t *cond;
52 #endif
53 int *result;
55 volatile int *counterp;
56 /* The next field is used in asynchronous `lio_listio' operations. */
57 struct sigevent *sigevp;
58 #ifdef BROKEN_THREAD_SIGNALS
59 /* XXX See requestlist, it's used to work around the broken signal
60 handling in Linux. */
61 pid_t caller_pid;
62 #endif
66 /* Status of a request. */
67 enum
69 no,
70 queued,
71 yes,
72 allocated,
73 done
77 /* Used to queue requests.. */
78 struct requestlist
80 int running;
82 struct requestlist *last_fd;
83 struct requestlist *next_fd;
84 struct requestlist *next_prio;
85 struct requestlist *next_run;
87 /* Pointer to the actual data. */
88 aiocb_union *aiocbp;
90 #ifdef BROKEN_THREAD_SIGNALS
91 /* PID of the initiator thread.
92 XXX This is only necessary for the broken signal handling on Linux. */
93 pid_t caller_pid;
94 #endif
96 /* List of waiting processes. */
97 struct waitlist *waiting;
101 /* Lock for global I/O list of requests. */
102 extern pthread_mutex_t __aio_requests_mutex attribute_hidden;
105 /* Enqueue request. */
106 extern struct requestlist *__aio_enqueue_request (aiocb_union *aiocbp,
107 int operation)
108 attribute_hidden internal_function;
110 /* Find request entry for given AIO control block. */
111 extern struct requestlist *__aio_find_req (aiocb_union *elem)
112 attribute_hidden internal_function;
114 /* Find request entry for given file descriptor. */
115 extern struct requestlist *__aio_find_req_fd (int fildes)
116 attribute_hidden internal_function;
118 /* Remove request from the list. */
119 extern void __aio_remove_request (struct requestlist *last,
120 struct requestlist *req, int all)
121 attribute_hidden internal_function;
123 /* Release the entry for the request. */
124 extern void __aio_free_request (struct requestlist *req)
125 attribute_hidden internal_function;
127 /* Notify initiator of request and tell this everybody listening. */
128 extern void __aio_notify (struct requestlist *req)
129 attribute_hidden internal_function;
131 /* Notify initiator of request. */
132 #ifdef BROKEN_THREAD_SIGNALS
133 extern int __aio_notify_only (struct sigevent *sigev, pid_t caller_pid)
134 attribute_hidden internal_function;
135 #else
136 extern int __aio_notify_only (struct sigevent *sigev)
137 attribute_hidden internal_function;
138 #endif
140 /* Send the signal. */
141 extern int __aio_sigqueue (int sig, const union sigval val, pid_t caller_pid)
142 attribute_hidden internal_function;
144 #endif /* aio_misc.h */