poll - Fix events == 0 handling for TAP and TUN, fix console spam
[dragonfly.git] / sys / sys / aio.h
blob157012d150d5d5ad5fef28943063bc6f8dac78c9
1 /*
2 * Copyright (c) 1997 John S. Dyson. All rights reserved.
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.
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.
16 * $FreeBSD: src/sys/sys/aio.h,v 1.13.2.8 2002/08/31 03:18:23 alc Exp $
19 #ifndef _SYS_AIO_H_
20 #define _SYS_AIO_H_
22 #include <sys/_timespec.h>
23 #include <sys/signal.h>
24 #include <machine/stdint.h>
26 #ifndef _OFF_T_DECLARED
27 typedef __off_t off_t;
28 #define _OFF_T_DECLARED
29 #endif
31 #ifndef _SIZE_T_DECLARED
32 #define _SIZE_T_DECLARED
33 typedef __size_t size_t;
34 #endif
36 #ifndef _SSIZE_T_DECLARED
37 #define _SSIZE_T_DECLARED
38 typedef __ssize_t ssize_t;
39 #endif
41 #ifndef _KERNEL
42 #ifndef _PTHREAD_ATTR_T_DECLARED
43 struct __pthread_attr_s;
44 typedef struct __pthread_attr_s *pthread_attr_t;
45 #define _PTHREAD_ATTR_T_DECLARED
46 #endif
47 #endif
50 * Returned by aio_cancel:
52 #define AIO_CANCELED 0x1
53 #define AIO_NOTCANCELED 0x2
54 #define AIO_ALLDONE 0x3
57 * LIO opcodes
59 #define LIO_NOP 0x0
60 #define LIO_WRITE 0x1
61 #define LIO_READ 0x2
64 * LIO modes
66 #define LIO_NOWAIT 0x0
67 #define LIO_WAIT 0x1
70 * Maximum number of allowed LIO operations
72 #define AIO_LISTIO_MAX 16
75 * I/O control block
77 typedef struct aiocb {
78 int aio_fildes; /* File descriptor */
79 off_t aio_offset; /* File offset for I/O */
80 volatile void *aio_buf; /* I/O buffer in process space */
81 size_t aio_nbytes; /* Number of bytes for I/O */
82 struct sigevent aio_sigevent; /* Signal to deliver */
83 int aio_lio_opcode; /* LIO opcode */
84 int aio_reqprio; /* Request priority -- ignored */
86 int _aio_val;
87 int _aio_err;
88 } aiocb_t;
90 #ifndef _KERNEL
92 __BEGIN_DECLS
94 * Asynchronously read from a file
96 int aio_read(struct aiocb *);
99 * Asynchronously write to file
101 int aio_write(struct aiocb *);
104 * List I/O Asynchronously/synchronously read/write to/from file
105 * "lio_mode" specifies whether or not the I/O is synchronous.
106 * "acb_list" is an array of "nacb_listent" I/O control blocks.
107 * when all I/Os are complete, the optional signal "sig" is sent.
109 int lio_listio(int, struct aiocb * __restrict const[__restrict_arr], int,
110 struct sigevent * __restrict);
113 * Get completion status
114 * returns EINPROGRESS until I/O is complete.
115 * this routine does not block.
117 int aio_error(const struct aiocb *);
120 * Finish up I/O, releasing I/O resources and returns the value
121 * that would have been associated with a synchronous I/O request.
122 * This routine must be called once and only once for each
123 * I/O control block who has had I/O associated with it.
125 ssize_t aio_return(struct aiocb *);
128 * Cancel I/O
130 int aio_cancel(int, struct aiocb *);
133 * Suspend until all specified I/O or timeout is complete.
135 int aio_suspend(const struct aiocb * const[], int, const struct timespec *);
138 * Synchronize I/O
140 int aio_fsync(int, struct aiocb *);
142 int aio_waitcomplete(struct aiocb **, struct timespec *);
144 __END_DECLS
146 #endif
148 #endif