2 * This Cplant(TM) source code is the property of Sandia National
5 * This Cplant(TM) source code is copyrighted by Sandia National
8 * The redistribution of this Cplant(TM) source code is subject to the
9 * terms of the GNU Lesser General Public License
10 * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html)
12 * Cplant(TM) Copyright 1998-2006 Sandia Corporation.
13 * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive
14 * license for use of this work by or on behalf of the US Government.
15 * Export of this program may require a license from the United States
20 * This library is free software; you can redistribute it and/or
21 * modify it under the terms of the GNU Lesser General Public
22 * License as published by the Free Software Foundation; either
23 * version 2.1 of the License, or (at your option) any later version.
25 * This library is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
28 * Lesser General Public License for more details.
30 * You should have received a copy of the GNU Lesser General Public
31 * License along with this library; if not, write to the Free Software
32 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
34 * Questions or comments about this library should be sent to:
37 * Sandia National Laboratories, New Mexico
39 * Albuquerque, NM 87185-1110
45 * System IO common information.
48 #if !defined(__IS_UNUSED) && defined(__GNUC__)
49 #define __IS_UNUSED __attribute__ ((unused))
54 #ifndef _LARGEFILE64_SOURCE
56 * Not glibc I guess. Define this ourselves.
58 #define _LARGEFILE64_SOURCE 0
62 * Define internal file-offset type and it's maximum value.
64 #if _LARGEFILE64_SOURCE
65 #define _SYSIO_OFF_T off64_t
67 #define _SYSIO_OFF_T_MAX (LLONG_MAX)
70 * Don't have LLONG_MAX before C99. We'll need to define it ourselves.
72 #define _SYSIO_OFF_T_MAX (9223372036854775807LL)
75 #define _SYSIO_OFF_T off_t
76 #define _SYSIO_OFF_T_MAX LONG_MAX
80 * Internally, all file status is carried in the 64-bit capable
83 #if _LARGEFILE64_SOURCE
84 #define intnl_xtvec xtvec64
86 #define intnl_xtvec xtvec
95 #define _PREPEND_HELPER(p, x) \
97 #define PREPEND(p, x) \
101 * SYSIO name label macros
103 #ifndef SYSIO_INTERFACE_NAME
104 #ifdef SYSIO_LABEL_NAMES
105 #define SYSIO_INTERFACE_NAME(x) \
106 PREPEND(SYSIO_LABEL_NAMES, x)
108 #define SYSIO_INTERFACE_NAME(x) x
109 #endif /* SYSIO_LABEL_NAMES */
110 #endif /* !SYSIO_INTERFACE_NAME */
114 #define ASSERT(cond) \
116 printf("ASSERTION(" #cond ") failed: " __FILE__ ":" \
117 __FUNCTION__ ":%d\n", __LINE__); \
121 #define ERROR(fmt, a...) \
123 printf("ERROR(" __FILE__ ":%d):" fmt, __LINE__, ##a); \
127 #define ERROR(fmt) do{}while(0)
128 #define ASSERT do{}while(0)
132 * SYSIO interface frame macros
134 * + DISPLAY_BLOCK; Allocates storage on the stack for use by the set of
136 * + ENTER; Performs entry point work
137 * + RETURN; Returns a value and performs exit point work
139 * NB: For RETURN, the arguments are the return value and value for errno.
140 * If the value for errno is non-zero then that value, *negated*, is set
143 #define SYSIO_INTERFACE_DISPLAY_BLOCK \
145 #define SYSIO_INTERFACE_ENTER \
147 _saved_errno = errno; \
150 #define SYSIO_INTERFACE_RETURN(rtn, err) \
153 errno = (err) ? -(err) : _saved_errno; \
157 /* Interface enter/leave hook functions */
159 extern void *_sysio_entry_trace_q;
160 extern void *_sysio_exit_trace_q;
162 extern void *_sysio_register_trace(void *q,
163 void (*)(const char *file,
168 void (*destructor)(void *data));
169 extern void _sysio_remove_trace(void *q, void *p);
170 extern void _sysio_run_trace_q(void *q,
174 #define SYSIO_ENTER \
176 _sysio_run_trace_q(_sysio_entry_trace_q, \
177 __FILE__, __func__, __LINE__); \
181 #define SYSIO_LEAVE \
183 _sysio_run_trace_q(_sysio_exit_trace_q, \
184 __FILE__, __func__, __LINE__); \
187 #define SYSIO_ENTER \
189 #define SYSIO_LEAVE \
193 /* Accounting for IO stats; Read and write character count. */
194 #if defined(REDSTORM)
195 #define _SYSIO_UPDACCT(w, cc) \
200 _add_iostats(0, (size_t )(cc)); \
202 _add_iostats((size_t )(cc), 0); \
205 #define _SYSIO_UPDACCT(w, cc)
208 extern ssize_t _sysio_validx(const struct intnl_xtvec *xtv, size_t xtvlen,
209 const struct iovec *iov, size_t iovlen,
211 extern ssize_t _sysio_enumerate_extents(const struct intnl_xtvec *xtv,
213 const struct iovec *iov,
215 ssize_t (*f)(const struct iovec *,
221 extern ssize_t _sysio_enumerate_iovec(const struct iovec *iov,
230 extern ssize_t _sysio_doio(const struct intnl_xtvec *xtv, size_t xtvlen,
231 const struct iovec *iov, size_t iovlen,
232 ssize_t (*f)(void *, size_t, _SYSIO_OFF_T, void *),