]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/sys/aio.h
This commit was generated by cvs2svn to compensate for changes in r38032,
[FreeBSD/FreeBSD.git] / sys / sys / aio.h
1 #ifndef _AIO_H_
2 #define _AIO_H_
3
4 /*
5  * Copyright (c) 1997 John S. Dyson.  All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. John S. Dyson's name may not be used to endorse or promote products
13  *    derived from this software without specific prior written permission.
14  *
15  * DISCLAIMER:  This code isn't warranted to do anything useful.  Anything
16  * bad that happens because of using this software isn't the responsibility
17  * of the author.  This software is distributed AS-IS.
18  *
19  * $Id: aio.h,v 1.7 1998/03/28 11:50:34 dufault Exp $
20  */
21
22 #include <sys/types.h>
23 #include <sys/signal.h>
24 /*
25  * Returned by aio_cancel:
26  *  (Note that FreeBSD's aio is not cancellable -- yet.)
27  */
28 #define AIO_CANCELED            0x1
29 #define AIO_NOTCANCELED       0x2
30 #define AIO_ALLDONE             0x3
31
32 /*
33  * LIO opcodes
34  */
35 #define LIO_NOP                 0x0
36 #define LIO_WRITE               0x1
37 #define LIO_READ                0x2
38
39 /*
40  * LIO modes
41  */
42 #define LIO_NOWAIT              0x0
43 #define LIO_WAIT                0x1
44
45 /*
46  * Maximum number of allowed LIO operations
47  */
48 #define AIO_LISTIO_MAX          16
49
50 /*
51  * Private mode bit for aio.
52  * (This bit is set by the library routine
53  *  to allow the kernel to support sync
54  *  or async operations in the future.)
55  */
56 #define AIO_PMODE_SYNC          0x1
57 #define AIO_PMODE_DONE          0x2
58 #define AIO_PMODE_SUSPEND       0x4
59 #define AIO_PMODE_ACTIVE        0x2357c0de
60
61 /*
62  * Private members for aiocb -- don't access
63  * directly.
64  */
65 struct __aiocb_private {
66         int     status;
67         int     error;
68         int     privatemodes;
69         int     active;
70         int     tid;
71         int     threadinfo;
72         void    *userinfo;
73         void    *kernelinfo;
74 };
75
76 /*
77  * I/O control block
78  */
79 typedef struct aiocb {
80         int     aio_fildes;             /* File descriptor */
81         off_t   aio_offset;             /* File offset for I/O */
82       volatile void *aio_buf;         /* I/O buffer in process space */
83         size_t  aio_nbytes;             /* Number of bytes for I/O */
84         struct  sigevent aio_sigevent;  /* Signal to deliver */
85         int     aio_lio_opcode;         /* LIO opcode */
86         int     aio_reqprio;            /* Request priority -- ignored */
87         struct  __aiocb_private _aiocb_private;
88 } aiocb_t;
89
90 #ifndef KERNEL
91 /*
92  * Asynchronously read from a file
93  */
94 int aio_read( struct aiocb *iocb);
95
96 /*
97  * Asynchronously write to file
98  */
99 int aio_write( struct aiocb *iocb);
100
101 /*
102  * List I/O Asynchronously/synchronously read/write to/from file
103  *      "lio_mode" specifies whether or not the I/O is synchronous.
104  *      "acb_list" is an array of "nacb_listent" I/O control blocks.
105  *      when all I/Os are complete, the optional signal "sig" is sent.
106  */
107 int lio_listio( int lio_mode, struct aiocb * const acb_list[],
108                int nacb_listent, struct sigevent *sig);
109
110 /*
111  * Get completion status
112  *      returns EINPROGRESS until I/O is complete.
113  *      this routine does not block.
114  */
115 int aio_error( const struct aiocb *iocb);
116
117 /*
118  * Finish up I/O, releasing I/O resources and returns the value
119  *      that would have been associated with a synchronous I/O request.
120  *      This routine must be called once and only once for each
121  *      I/O control block who has had I/O associated with it.
122  */
123 ssize_t aio_return( struct aiocb *iocb);
124
125 /*
126  * Cancel I/O -- implemented only to return AIO_NOTCANCELLED or
127  *      AIO_ALLDONE.  No cancellation operation will occur.
128  */
129 int aio_cancel( int fd, struct aiocb *iocb);
130
131 /*
132  * Suspend until all specified I/O or timeout is complete.
133  */
134 int aio_suspend( const struct aiocb * const acb_list[], int nacb_listent,
135                const struct timespec *tm);
136
137 /*
138  * Retrieve the status of the specified I/O request.
139  */
140 int aio_error( const struct aiocb *aiocbp);
141
142 #else
143
144 void    aio_proc_rundown( struct proc *p);
145
146 #endif
147
148 #endif
149