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$ 17 */ 18 19#ifndef _SYS_AIO_H_ 20#define _SYS_AIO_H_ 21 22#include <sys/types.h> 23#include <sys/signal.h> 24 25/* 26 * Returned by aio_cancel: 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#ifdef _KERNEL 39#define LIO_SYNC 0x3 40#endif 41 42/* 43 * LIO modes 44 */ 45#define LIO_NOWAIT 0x0 46#define LIO_WAIT 0x1 47 48/* 49 * Maximum number of allowed LIO operations 50 */ 51#define AIO_LISTIO_MAX 16 52 53/* 54 * Private members for aiocb -- don't access 55 * directly. 56 */ 57struct __aiocb_private { 58 long status; 59 long error; 60 void *kernelinfo; 61}; 62 63/* 64 * I/O control block 65 */ 66typedef struct aiocb { 67 int aio_fildes; /* File descriptor */ 68 off_t aio_offset; /* File offset for I/O */ 69 volatile void *aio_buf; /* I/O buffer in process space */ 70 size_t aio_nbytes; /* Number of bytes for I/O */ 71 int __spare__[2]; 72 void *__spare2__; 73 int aio_lio_opcode; /* LIO opcode */ 74 int aio_reqprio; /* Request priority -- ignored */ 75 struct __aiocb_private _aiocb_private; 76 struct sigevent aio_sigevent; /* Signal to deliver */ 77} aiocb_t; 78 79#ifndef _KERNEL 80 81struct timespec; 82 83__BEGIN_DECLS 84/* 85 * Asynchronously read from a file 86 */ 87int aio_read(struct aiocb *); 88 89/* 90 * Asynchronously write to file 91 */ 92int aio_write(struct aiocb *); 93 94/* 95 * List I/O Asynchronously/synchronously read/write to/from file 96 * "lio_mode" specifies whether or not the I/O is synchronous. 97 * "acb_list" is an array of "nacb_listent" I/O control blocks. 98 * when all I/Os are complete, the optional signal "sig" is sent. 99 */ 100int lio_listio(int, struct aiocb * const [], int, struct sigevent *); 101 102/* 103 * Get completion status 104 * returns EINPROGRESS until I/O is complete. 105 * this routine does not block. 106 */ 107int aio_error(const struct aiocb *); 108 109/* 110 * Finish up I/O, releasing I/O resources and returns the value 111 * that would have been associated with a synchronous I/O request. 112 * This routine must be called once and only once for each 113 * I/O control block who has had I/O associated with it. 114 */ 115ssize_t aio_return(struct aiocb *); 116 117/* 118 * Cancel I/O 119 */ 120int aio_cancel(int, struct aiocb *); 121 122/* 123 * Suspend until all specified I/O or timeout is complete. 124 */ 125int aio_suspend(const struct aiocb * const[], int, const struct timespec *); 126 127#ifdef __BSD_VISIBLE 128int aio_waitcomplete(struct aiocb **, struct timespec *); 129#endif 130 131int aio_fsync(int op, struct aiocb *aiocbp); 132__END_DECLS 133 134#else 135 136/* Forward declarations for prototypes below. */ 137struct socket; 138struct sockbuf; 139 140extern void (*aio_swake)(struct socket *, struct sockbuf *); 141 142#endif 143 144#endif 145