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