]>
Commit | Line | Data |
---|---|---|
b168057a | 1 | /* Copyright (C) 1997-2015 Free Software Foundation, Inc. |
cbdee279 UD |
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 | |
41bdb6e2 AJ |
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. | |
cbdee279 UD |
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 | |
41bdb6e2 | 12 | Lesser General Public License for more details. |
cbdee279 | 13 | |
41bdb6e2 | 14 | You should have received a copy of the GNU Lesser General Public |
59ba27a6 PE |
15 | License along with the GNU C Library; if not, see |
16 | <http://www.gnu.org/licenses/>. */ | |
cbdee279 UD |
17 | |
18 | #ifndef _AIO_MISC_H | |
19 | #define _AIO_MISC_H 1 | |
20 | ||
d71b808a UD |
21 | #include <aio.h> |
22 | #include <pthread.h> | |
23 | ||
24 | ||
25 | /* Extend the operation enum. */ | |
26 | enum | |
27 | { | |
b8744bea | 28 | LIO_DSYNC = LIO_NOP + 1, |
d71b808a UD |
29 | LIO_SYNC, |
30 | LIO_READ64 = LIO_READ | 128, | |
31 | LIO_WRITE64 = LIO_WRITE | 128 | |
32 | }; | |
33 | ||
cbdee279 UD |
34 | |
35 | /* Union of the two request types. */ | |
36 | typedef union | |
37 | { | |
38 | struct aiocb aiocb; | |
39 | struct aiocb64 aiocb64; | |
40 | } aiocb_union; | |
41 | ||
d71b808a UD |
42 | |
43 | /* Used to synchronize. */ | |
44 | struct waitlist | |
45 | { | |
46 | struct waitlist *next; | |
47 | ||
9759bbf1 | 48 | /* The next two fields is used in synchronous `lio_listio' operations. */ |
679d83ba | 49 | #ifndef DONT_NEED_AIO_MISC_COND |
d71b808a | 50 | pthread_cond_t *cond; |
679d83ba | 51 | #endif |
9759bbf1 UD |
52 | int *result; |
53 | ||
d71b808a UD |
54 | volatile int *counterp; |
55 | /* The next field is used in asynchronous `lio_listio' operations. */ | |
56 | struct sigevent *sigevp; | |
b61c8aba | 57 | #ifdef BROKEN_THREAD_SIGNALS |
3a9eb648 UD |
58 | /* XXX See requestlist, it's used to work around the broken signal |
59 | handling in Linux. */ | |
60 | pid_t caller_pid; | |
b61c8aba | 61 | #endif |
d71b808a UD |
62 | }; |
63 | ||
64 | ||
65 | /* Status of a request. */ | |
66 | enum | |
67 | { | |
68 | no, | |
69 | queued, | |
70 | yes, | |
56ddf355 UD |
71 | allocated, |
72 | done | |
d71b808a UD |
73 | }; |
74 | ||
75 | ||
76 | /* Used to queue requests.. */ | |
77 | struct requestlist | |
78 | { | |
79 | int running; | |
80 | ||
81 | struct requestlist *last_fd; | |
82 | struct requestlist *next_fd; | |
83 | struct requestlist *next_prio; | |
84 | struct requestlist *next_run; | |
85 | ||
86 | /* Pointer to the actual data. */ | |
87 | aiocb_union *aiocbp; | |
88 | ||
b61c8aba | 89 | #ifdef BROKEN_THREAD_SIGNALS |
3a9eb648 UD |
90 | /* PID of the initiator thread. |
91 | XXX This is only necessary for the broken signal handling on Linux. */ | |
92 | pid_t caller_pid; | |
b61c8aba | 93 | #endif |
3a9eb648 | 94 | |
d71b808a UD |
95 | /* List of waiting processes. */ |
96 | struct waitlist *waiting; | |
97 | }; | |
98 | ||
cbdee279 UD |
99 | |
100 | /* Lock for global I/O list of requests. */ | |
67b78ef9 | 101 | extern pthread_mutex_t __aio_requests_mutex attribute_hidden; |
cbdee279 UD |
102 | |
103 | ||
104 | /* Enqueue request. */ | |
d71b808a UD |
105 | extern struct requestlist *__aio_enqueue_request (aiocb_union *aiocbp, |
106 | int operation) | |
67b78ef9 | 107 | attribute_hidden internal_function; |
d71b808a UD |
108 | |
109 | /* Find request entry for given AIO control block. */ | |
110 | extern struct requestlist *__aio_find_req (aiocb_union *elem) | |
67b78ef9 | 111 | attribute_hidden internal_function; |
d71b808a UD |
112 | |
113 | /* Find request entry for given file descriptor. */ | |
67b78ef9 UD |
114 | extern struct requestlist *__aio_find_req_fd (int fildes) |
115 | attribute_hidden internal_function; | |
d71b808a | 116 | |
92806ee9 UD |
117 | /* Remove request from the list. */ |
118 | extern void __aio_remove_request (struct requestlist *last, | |
119 | struct requestlist *req, int all) | |
67b78ef9 | 120 | attribute_hidden internal_function; |
92806ee9 | 121 | |
d71b808a | 122 | /* Release the entry for the request. */ |
67b78ef9 UD |
123 | extern void __aio_free_request (struct requestlist *req) |
124 | attribute_hidden internal_function; | |
d71b808a UD |
125 | |
126 | /* Notify initiator of request and tell this everybody listening. */ | |
67b78ef9 UD |
127 | extern void __aio_notify (struct requestlist *req) |
128 | attribute_hidden internal_function; | |
d71b808a UD |
129 | |
130 | /* Notify initiator of request. */ | |
b61c8aba | 131 | #ifdef BROKEN_THREAD_SIGNALS |
3a9eb648 | 132 | extern int __aio_notify_only (struct sigevent *sigev, pid_t caller_pid) |
67b78ef9 | 133 | attribute_hidden internal_function; |
b61c8aba UD |
134 | #else |
135 | extern int __aio_notify_only (struct sigevent *sigev) | |
136 | attribute_hidden internal_function; | |
137 | #endif | |
cbdee279 UD |
138 | |
139 | /* Send the signal. */ | |
3a9eb648 | 140 | extern int __aio_sigqueue (int sig, const union sigval val, pid_t caller_pid) |
67b78ef9 | 141 | attribute_hidden internal_function; |
cbdee279 UD |
142 | |
143 | #endif /* aio_misc.h */ |