• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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 */
44 #if defined(__linux__) && !defined(__UCLIBC__)
45 #define LIO_IO_TYPES            00061   /* all io types */
46 #define LIO_IO_ATYPES           00077   /* all io types */
47 #endif
48 #if defined(__sun) || defined(__hpux) || defined(_AIX) || defined(__UCLIBC__)
49 #define LIO_IO_TYPES            00021   /* all io types except pread/pwrite */
50 #endif /* linux */
51 #ifdef CRAY
52 #define LIO_IO_TYPES            00017   /* all io types */
53 #endif /* CRAY */
54 
55 #ifndef LIO_IO_ATYPES
56 #define LIO_IO_ATYPES LIO_IO_TYPES
57 #endif
58 
59 #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 */
64 #if defined(sgi) || defined(__linux__)
65 #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 */
70 #if defined(__sun) || defined(__hpux) || defined(_AIX)
71 #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 
80 #if defined(sgi) || defined(__linux__)
81 /* 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 */
88 #if defined(__sun) || defined(__hpux) || defined(_AIX)
89 /* 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 
120 int  stride_bounds(int offset, int stride, int nstrides,
121 		      int bytes_per_stride, int *min_byte, int *max_byte);
122 
123 int  lio_set_debug(int level);
124 int  lio_parse_io_arg1(char *string);
125 void lio_help1(char *prefex);
126 int  lio_parse_io_arg2(char *string, char **badtoken);
127 void lio_help2(char *prefex);
128 int  lio_write_buffer(int fd, int method, char *buffer, int size,
129 		      int sig, char **errmsg, long wrd);
130 
131 int  lio_read_buffer(int fd, int method, char *buffer, int size,
132 		     int sig, char **errmsg, long wrd);
133 int  lio_random_methods(long mask);
134 
135 #if CRAY
136 #include <sys/iosw.h>
137 int  lio_wait4asyncio(int method, int fd, struct iosw **statptr);
138 int  lio_check_asyncio(char *io_type, int size, struct iosw *status);
139 #endif /* CRAY */
140 #if defined (sgi)
141 #include <aio.h>
142 int  lio_wait4asyncio(int method, int fd, aiocb_t *aiocbp);
143 int  lio_check_asyncio(char *io_type, int size, aiocb_t *aiocbp, int method);
144 #endif /* sgi */
145 #if defined(__linux__) && !defined(__UCLIBC__)
146 #include <aio.h>
147 int  lio_wait4asyncio(int method, int fd, struct aiocb *aiocbp);
148 int  lio_check_asyncio(char *io_type, int size, struct aiocb *aiocbp, int method);
149 #endif
150 
151 /*
152  * Define the structure that contains the infomation that is used
153  * by the parsing and help functions.
154  */
155 struct lio_info_type {
156     char *token;
157     int  bits;
158     char *desc;
159 };
160 
161 
162