blob: 2d257d8bb15bd9b35b0e5f5185415e8619ea281d [file] [log] [blame]
whrb973f2b2000-05-05 19:34:50 +00001/*
2 * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of version 2 of the GNU General Public License as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it would be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 *
12 * Further, this software is distributed without any warranty that it is
13 * free of the rightful claim of any third person regarding infringement
14 * or the like. Any license provided herein, whether implied or
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/NoticeExplan/
31 */
32
33#define LIO_IO_SYNC 00001 /* read/write */
34#define LIO_IO_ASYNC 00002 /* reada/writea/aio_write/aio_read */
35#define LIO_IO_SLISTIO 00004 /* single stride sync listio */
36#define LIO_IO_ALISTIO 00010 /* single stride async listio */
37#define LIO_IO_SYNCV 00020 /* single-buffer readv/writev */
38#define LIO_IO_SYNCP 00040 /* pread/pwrite */
39
40#ifdef sgi
41#define LIO_IO_ATYPES 00077 /* all io types */
42#define LIO_IO_TYPES 00061 /* all io types, non-async */
43#endif /* sgi */
subrata_modake5e938f2009-04-13 13:58:20 +000044#if defined(__linux__) && !defined(__UCLIBC__)
subrata_modakea37be82008-12-11 13:17:49 +000045#define LIO_IO_TYPES 00061 /* all io types */
46#define LIO_IO_ATYPES 00077 /* all io types */
47#endif
subrata_modake5e938f2009-04-13 13:58:20 +000048#if defined(__sun) || defined(__hpux) || defined(_AIX) || defined(__UCLIBC__)
49#define LIO_IO_TYPES 00021 /* all io types except pread/pwrite */
whrb973f2b2000-05-05 19:34:50 +000050#endif /* linux */
51#ifdef CRAY
52#define LIO_IO_TYPES 00017 /* all io types */
53#endif /* CRAY */
54
subrata_modakea37be82008-12-11 13:17:49 +000055#ifndef LIO_IO_ATYPES
56#define LIO_IO_ATYPES LIO_IO_TYPES
57#endif
58
whrb973f2b2000-05-05 19:34:50 +000059#define LIO_WAIT_NONE 00010000 /* return asap -- use with care */
60#define LIO_WAIT_ACTIVE 00020000 /* spin looking at iosw fields, or EINPROGRESS */
61#define LIO_WAIT_RECALL 00040000 /* call recall(2)/aio_suspend(3) */
62#define LIO_WAIT_SIGPAUSE 00100000 /* call pause */
63#define LIO_WAIT_SIGACTIVE 00200000 /* spin waiting for signal */
subrata_modake5e938f2009-04-13 13:58:20 +000064#if defined(sgi) || defined(__linux__) || !defined(__UCLIBC__)
whrb973f2b2000-05-05 19:34:50 +000065#define LIO_WAIT_CBSUSPEND 00400000 /* aio_suspend waiting for callback */
66#define LIO_WAIT_SIGSUSPEND 01000000 /* aio_suspend waiting for signal */
67#define LIO_WAIT_ATYPES 01760000 /* all async wait types, except nowait */
68#define LIO_WAIT_TYPES 00020000 /* all sync wait types (sorta) */
69#endif /* sgi */
subrata_modake5e938f2009-04-13 13:58:20 +000070#if defined(__sun) || defined(__hpux) || defined(_AIX) || defined(__UCLIBC__)
whrb973f2b2000-05-05 19:34:50 +000071#define LIO_WAIT_TYPES 00300000 /* all wait types, except nowait */
72#endif /* linux */
73#ifdef CRAY
74#define LIO_WAIT_TYPES 00360000 /* all wait types, except nowait */
75#endif /* CRAY */
76
77/* meta wait io */
78/* 00 000 0000 */
79
subrata_modakea37be82008-12-11 13:17:49 +000080#if defined(sgi) || defined(__linux__)
whrb973f2b2000-05-05 19:34:50 +000081/* all callback wait types */
82#define LIO_WAIT_CBTYPES (LIO_WAIT_CBSUSPEND)
83/* all signal wait types */
84#define LIO_WAIT_SIGTYPES (LIO_WAIT_SIGPAUSE|LIO_WAIT_SIGACTIVE|LIO_WAIT_SIGSUSPEND)
85/* all aio_{read,write} or lio_listio */
86#define LIO_IO_ASYNC_TYPES (LIO_IO_ASYNC|LIO_IO_SLISTIO|LIO_IO_ALISTIO)
87#endif /* sgi */
subrata_modakea37be82008-12-11 13:17:49 +000088#if defined(__sun) || defined(__hpux) || defined(_AIX)
whrb973f2b2000-05-05 19:34:50 +000089/* all signal wait types */
90#define LIO_WAIT_SIGTYPES (LIO_WAIT_SIGPAUSE)
91#endif /* linux */
92#ifdef CRAY
93/* all signal wait types */
94#define LIO_WAIT_SIGTYPES (LIO_WAIT_SIGPAUSE|LIO_WAIT_SIGACTIVE)
95#endif /* CRAY */
96
97/*
98 * This bit provides a way to randomly pick an io type and wait method.
99 * lio_read_buffer() and lio_write_buffer() functions will call
100 * lio_random_methods() with the given method.
101 */
102#define LIO_RANDOM 010000000
103
104/*
105 * This bit provides a way for the programmer to use async i/o with
106 * signals and to use their own signal handler. By default,
107 * the signal will only be given to the system call if the wait
108 * method is LIO_WAIT_SIGPAUSE or LIO_WAIT_SIGACTIVE.
109 * Whenever these wait methods are used, libio signal handler
110 * will be used.
111 */
112#define LIO_USE_SIGNAL 020000000
113
114/*
115 * prototypes/structures for functions in the libio.c module. See comments
116 * in that module, or man page entries for information on the individual
117 * functions.
118 */
119
120int stride_bounds(int offset, int stride, int nstrides,
121 int bytes_per_stride, int *min_byte, int *max_byte);
122
123int lio_set_debug(int level);
124int lio_parse_io_arg1(char *string);
125void lio_help1(char *prefex);
126int lio_parse_io_arg2(char *string, char **badtoken);
127void lio_help2(char *prefex);
128int lio_write_buffer(int fd, int method, char *buffer, int size,
129 int sig, char **errmsg, long wrd);
130
131int lio_read_buffer(int fd, int method, char *buffer, int size,
132 int sig, char **errmsg, long wrd);
133int lio_random_methods(long mask);
134
135#if CRAY
136#include <sys/iosw.h>
137int lio_wait4asyncio(int method, int fd, struct iosw **statptr);
138int lio_check_asyncio(char *io_type, int size, struct iosw *status);
139#endif /* CRAY */
subrata_modakea37be82008-12-11 13:17:49 +0000140#if defined (sgi)
whrb973f2b2000-05-05 19:34:50 +0000141#include <aio.h>
142int lio_wait4asyncio(int method, int fd, aiocb_t *aiocbp);
143int lio_check_asyncio(char *io_type, int size, aiocb_t *aiocbp, int method);
144#endif /* sgi */
subrata_modak26e07d52009-02-26 06:33:39 +0000145#if defined(__linux__) && !defined(__UCLIBC__)
subrata_modakea37be82008-12-11 13:17:49 +0000146#include <aio.h>
147int lio_wait4asyncio(int method, int fd, struct aiocb *aiocbp);
148int lio_check_asyncio(char *io_type, int size, struct aiocb *aiocbp, int method);
149#endif
whrb973f2b2000-05-05 19:34:50 +0000150
151/*
152 * Define the structure that contains the infomation that is used
153 * by the parsing and help functions.
154 */
155struct lio_info_type {
156 char *token;
157 int bits;
158 char *desc;
159};
160
161