kernel - Add fuwordadd32(), fuwordadd64()
[dragonfly.git] / sys / sys / aio.h
1 /*
2  * Copyright (c) 1997 John S. Dyson.  All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. John S. Dyson's name may not be used to endorse or promote products
10  *    derived from this software without specific prior written permission.
11  *
12  * DISCLAIMER:  This code isn't warranted to do anything useful.  Anything
13  * bad that happens because of using this software isn't the responsibility
14  * of the author.  This software is distributed AS-IS.
15  *
16  * $FreeBSD: src/sys/sys/aio.h,v 1.13.2.8 2002/08/31 03:18:23 alc Exp $
17  */
18
19 #ifndef _SYS_AIO_H_
20 #define _SYS_AIO_H_
21
22 #include <sys/_pthreadtypes.h>
23 #include <sys/_timespec.h>
24 #include <sys/signal.h>
25 #include <sys/stdint.h>
26
27 #ifndef _OFF_T_DECLARED
28 typedef __off_t         off_t;
29 #define _OFF_T_DECLARED
30 #endif
31
32 #ifndef _SIZE_T_DECLARED
33 #define _SIZE_T_DECLARED
34 typedef __size_t        size_t;
35 #endif
36
37 #ifndef _SSIZE_T_DECLARED
38 #define _SSIZE_T_DECLARED
39 typedef __ssize_t       ssize_t;
40 #endif
41
42 /*
43  * Returned by aio_cancel:
44  */
45 #define AIO_CANCELED            0x1
46 #define AIO_NOTCANCELED         0x2
47 #define AIO_ALLDONE             0x3
48
49 /*
50  * LIO opcodes
51  */
52 #define LIO_NOP                 0x0
53 #define LIO_WRITE               0x1
54 #define LIO_READ                0x2
55
56 /*
57  * LIO modes
58  */
59 #define LIO_NOWAIT              0x0
60 #define LIO_WAIT                0x1
61
62 /*
63  * Maximum number of allowed LIO operations
64  */
65 #define AIO_LISTIO_MAX          16
66
67 /*
68  * I/O control block
69  */
70 typedef struct aiocb {
71         int     aio_fildes;             /* File descriptor */
72         off_t   aio_offset;             /* File offset for I/O */
73         volatile void *aio_buf;         /* I/O buffer in process space */
74         size_t  aio_nbytes;             /* Number of bytes for I/O */
75         struct  sigevent aio_sigevent;  /* Signal to deliver */
76         int     aio_lio_opcode;         /* LIO opcode */
77         int     aio_reqprio;            /* Request priority -- ignored */
78
79         int     _aio_val;
80         int     _aio_err;
81 } aiocb_t;
82
83 #ifndef _KERNEL
84
85 __BEGIN_DECLS
86 /*
87  * Asynchronously read from a file
88  */
89 int     aio_read(struct aiocb *);
90
91 /*
92  * Asynchronously write to file
93  */
94 int     aio_write(struct aiocb *);
95
96 /*
97  * List I/O Asynchronously/synchronously read/write to/from file
98  *      "lio_mode" specifies whether or not the I/O is synchronous.
99  *      "acb_list" is an array of "nacb_listent" I/O control blocks.
100  *      when all I/Os are complete, the optional signal "sig" is sent.
101  */
102 int     lio_listio(int, struct aiocb * __restrict const[__restrict_arr], int,
103             struct sigevent * __restrict);
104
105 /*
106  * Get completion status
107  *      returns EINPROGRESS until I/O is complete.
108  *      this routine does not block.
109  */
110 int     aio_error(const struct aiocb *);
111
112 /*
113  * Finish up I/O, releasing I/O resources and returns the value
114  *      that would have been associated with a synchronous I/O request.
115  *      This routine must be called once and only once for each
116  *      I/O control block who has had I/O associated with it.
117  */
118 ssize_t aio_return(struct aiocb *);
119
120 /*
121  * Cancel I/O
122  */
123 int     aio_cancel(int, struct aiocb *);
124
125 /*
126  * Suspend until all specified I/O or timeout is complete.
127  */
128 int     aio_suspend(const struct aiocb * const[], int, const struct timespec *);
129
130 /*
131  * Synchronize I/O
132  */
133 int     aio_fsync(int, struct aiocb *);
134
135 int     aio_waitcomplete(struct aiocb **, struct timespec *);
136
137 __END_DECLS
138
139 #endif
140
141 #endif