Allow LDFLAGS to come from build env, for the Gentoo fringe dwellers.
[xfstests-dev.git] / include / tlibio.h
1 /*
2  * Copyright (c) 2000 Silicon Graphics, Inc.
3  * All Rights Reserved.
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License as
7  * published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope that it would be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write the Free Software Foundation,
16  * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17  */
18
19 #define LIO_IO_SYNC             00001   /* read/write */
20 #define LIO_IO_ASYNC            00002   /* reada/writea/aio_write/aio_read */
21 #define LIO_IO_SLISTIO          00004   /* single stride sync listio */
22 #define LIO_IO_ALISTIO          00010   /* single stride async listio */
23 #define LIO_IO_SYNCV            00020   /* single-buffer readv/writev */
24 #define LIO_IO_SYNCP            00040   /* pread/pwrite */
25
26 #ifdef sgi
27 #define LIO_IO_ATYPES           00077   /* all io types */
28 #define LIO_IO_TYPES            00061   /* all io types, non-async */
29 #endif /* sgi */
30 #ifdef linux
31 #define LIO_IO_TYPES            00021   /* all io types */
32 #endif /* linux */
33 #ifdef CRAY
34 #define LIO_IO_TYPES            00017   /* all io types */
35 #endif /* CRAY */
36
37 #define LIO_WAIT_NONE           00010000 /* return asap -- use with care */
38 #define LIO_WAIT_ACTIVE         00020000 /* spin looking at iosw fields, or EINPROGRESS */
39 #define LIO_WAIT_RECALL         00040000 /* call recall(2)/aio_suspend(3) */
40 #define LIO_WAIT_SIGPAUSE       00100000 /* call pause */
41 #define LIO_WAIT_SIGACTIVE      00200000 /* spin waiting for signal */
42 #ifdef sgi
43 #define LIO_WAIT_CBSUSPEND      00400000 /* aio_suspend waiting for callback */
44 #define LIO_WAIT_SIGSUSPEND     01000000 /* aio_suspend waiting for signal */
45 #define LIO_WAIT_ATYPES         01760000 /* all async wait types, except nowait */
46 #define LIO_WAIT_TYPES          00020000 /* all sync wait types (sorta) */
47 #endif /* sgi */
48 #ifdef linux
49 #define LIO_WAIT_TYPES          00300000 /* all wait types, except nowait */
50 #endif /* linux */
51 #ifdef CRAY
52 #define LIO_WAIT_TYPES          00360000 /* all wait types, except nowait */
53 #endif /* CRAY */
54
55 /* meta wait io  */
56 /*  00  000 0000 */
57
58 #ifdef sgi
59 /* all callback wait types */
60 #define LIO_WAIT_CBTYPES        (LIO_WAIT_CBSUSPEND)
61 /* all signal wait types */
62 #define LIO_WAIT_SIGTYPES       (LIO_WAIT_SIGPAUSE|LIO_WAIT_SIGACTIVE|LIO_WAIT_SIGSUSPEND)
63 /* all aio_{read,write} or lio_listio */
64 #define LIO_IO_ASYNC_TYPES      (LIO_IO_ASYNC|LIO_IO_SLISTIO|LIO_IO_ALISTIO)
65 #endif /* sgi */
66 #ifdef linux
67 /* all signal wait types */
68 #define LIO_WAIT_SIGTYPES       (LIO_WAIT_SIGPAUSE)
69 #endif /* linux */
70 #ifdef CRAY
71 /* all signal wait types */
72 #define LIO_WAIT_SIGTYPES       (LIO_WAIT_SIGPAUSE|LIO_WAIT_SIGACTIVE)
73 #endif /* CRAY */
74
75 /*
76  * This bit provides a way to randomly pick an io type and wait method.
77  * lio_read_buffer() and lio_write_buffer() functions will call
78  * lio_random_methods() with the given method.
79  */
80 #define LIO_RANDOM              010000000
81
82 /*
83  * This bit provides a way for the programmer to use async i/o with
84  * signals and to use their own signal handler.  By default,
85  * the signal will only be given to the system call if the wait
86  * method is LIO_WAIT_SIGPAUSE or LIO_WAIT_SIGACTIVE.
87  * Whenever these wait methods are used, libio signal handler
88  * will be used.
89  */
90 #define LIO_USE_SIGNAL          020000000
91
92 /*
93  * prototypes/structures for functions in the libio.c module.  See comments
94  * in that module, or man page entries for information on the individual
95  * functions.
96  */
97
98 int  stride_bounds(int offset, int stride, int nstrides,
99                       int bytes_per_stride, int *min_byte, int *max_byte);
100
101 int  lio_set_debug(int level);
102 int  lio_parse_io_arg1(char *string);
103 void lio_help1(char *prefex);
104 int  lio_parse_io_arg2(char *string, char **badtoken);
105 void lio_help2(char *prefex);
106 int  lio_write_buffer(int fd, int method, char *buffer, int size,
107                       int sig, char **errmsg, long wrd);
108
109 int  lio_read_buffer(int fd, int method, char *buffer, int size,
110                      int sig, char **errmsg, long wrd);
111 int  lio_random_methods(long mask);
112
113 #if CRAY
114 #include <sys/iosw.h>
115 int  lio_wait4asyncio(int method, int fd, struct iosw **statptr);
116 int  lio_check_asyncio(char *io_type, int size, struct iosw *status);
117 #endif /* CRAY */
118 #ifdef sgi
119 #include <aio.h>
120 int  lio_wait4asyncio(int method, int fd, aiocb_t *aiocbp);
121 int  lio_check_asyncio(char *io_type, int size, aiocb_t *aiocbp, int method);
122 #endif /* sgi */
123
124 /*
125  * Define the structure that contains the infomation that is used
126  * by the parsing and help functions.
127  */
128 struct lio_info_type {
129     char *token;
130     int  bits;
131     char *desc;
132 };
133
134