Whamcloud - gitweb
140981721960365cb363ab10d0138abac0d67f6d
[fs/lustre-release.git] / libsysio / include / native.h
1 /*
2  *    This Cplant(TM) source code is the property of Sandia National
3  *    Laboratories.
4  *
5  *    This Cplant(TM) source code is copyrighted by Sandia National
6  *    Laboratories.
7  *
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)
11  *
12  *    Cplant(TM) Copyright 1998-2004 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
16  *    Government.
17  */
18
19 /*
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.
24  * 
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.
29  * 
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
33  *
34  * Questions or comments about this library should be sent to:
35  *
36  * Lee Ward
37  * Sandia National Laboratories, New Mexico
38  * P.O. Box 5800
39  * Albuquerque, NM 87185-1110
40  *
41  * lee@sandia.gov
42  */
43
44 /*
45  * Native file system support.
46  */
47
48 #if ALPHA_LINUX
49
50 /*
51  * stat struct from asm/stat.h, as returned 
52  * by alpha linux kernel
53  */
54 struct _sysio_native_stat {
55         unsigned int    st_dev;
56         unsigned int    st_ino;
57         unsigned int    st_mode;
58         unsigned int    st_nlink;
59         unsigned int    st_uid;
60         unsigned int    st_gid;
61         unsigned int    st_rdev;
62         long            st_size;
63         unsigned long   st_atime;
64         unsigned long   st_mtime;
65         unsigned long   st_ctime;
66         unsigned int    st_blksize;
67         int             st_blocks;
68         unsigned int    st_flags;
69         unsigned int    st_gen;
70 };
71
72 #define SYSIO_COPY_STAT(src, dest)                    \
73 do {                                            \
74         memset((dest), 0, sizeof((*dest)));     \
75         (dest)->st_dev     = (src)->st_dev;     \
76         (dest)->st_ino     = (src)->st_ino;     \
77         (dest)->st_mode    = (src)->st_mode;    \
78         (dest)->st_nlink   = (src)->st_nlink;   \
79         (dest)->st_uid     = (src)->st_uid;     \
80         (dest)->st_gid     = (src)->st_gid;     \
81         (dest)->st_rdev    = (src)->st_rdev;    \
82         (dest)->st_size    = (src)->st_size;    \
83         (dest)->st_atime   = (src)->st_atime;   \
84         (dest)->st_mtime   = (src)->st_mtime;   \
85         (dest)->st_ctime   = (src)->st_ctime;   \
86         (dest)->st_blksize = (src)->st_blksize; \
87         (dest)->st_blocks  = (src)->st_blocks;  \
88         (dest)->st_flags   = (src)->st_flags;   \
89         (dest)->st_gen     = (src)->st_gen;     \
90 } while (0);
91
92 #else 
93 #define _sysio_native_stat intnl_stat
94 #define SYSIO_COPY_STAT(src, dest) *(dest) = *(src) 
95 #endif
96
97 /*
98  * System calls.
99  */
100 #if _LARGEFILE64_SOURCE && defined(SYS_lstat64)
101 #define SYSIO_SYS_stat          SYS_lstat64
102 #elif defined(SYS_lstat)
103 #define SYSIO_SYS_stat          SYS_lstat
104 #endif
105 #if _LARGEFILE64_SOURCE && defined(SYS_fstat64)
106 #define SYSIO_SYS_fstat         SYS_fstat64
107 #elif defined(SYS_fstat)
108 #define SYSIO_SYS_fstat         SYS_fstat
109 #endif
110 #if _LARGEFILE64_SOURCE && defined(SYS_truncate64)
111 #define SYSIO_SYS_truncate      SYS_truncate64
112 #elif defined(SYS_truncate)
113 #define SYSIO_SYS_truncate      SYS_truncate
114 #endif
115 #if _LARGEFILE64_SOURCE && defined(SYS_ftruncate64)
116 #define SYSIO_SYS_ftruncate     SYS_ftruncate64
117 #elif defined(SYS_ftruncate)
118 #define SYSIO_SYS_ftruncate     SYS_ftruncate
119 #endif
120 #if defined(SYS_open)
121 #define SYSIO_SYS_open          SYS_open
122 #endif
123 #if defined(SYS_close)
124 #define SYSIO_SYS_close         SYS_close
125 #endif
126 #if _LARGEFILE64_SOURCE && defined(SYS_lseek64)
127 #define SYSIO_SYS_lseek         SYS_lseek64
128 #elif defined(SYS_lseek)
129 #define SYSIO_SYS_lseek         SYS_lseek
130 #endif
131 #if defined(SYS__llseek)
132 #define SYSIO_SYS__llseek       SYS__llseek
133 #endif
134 #if defined(SYS_read)
135 #define SYSIO_SYS_read          SYS_read
136 #endif
137 #if defined(SYS_write)
138 #define SYSIO_SYS_write         SYS_write
139 #endif
140 #if defined(SYS_readv)
141 #define SYSIO_SYS_readv         SYS_readv
142 #endif
143 #if defined(SYS_writev)
144 #define SYSIO_SYS_writev        SYS_writev
145 #endif
146 #if _LARGEFILE64_SOURCE && defined(SYS_pread64)
147 #define SYSIO_SYS_pread         SYS_pread64
148 #elif defined(SYS_pread)
149 #define SYSIO_SYS_pread         SYS_pread
150 #endif
151 #if _LARGEFILE64_SOURCE && defined(SYS_pwrite64)
152 #define SYSIO_SYS_pwrite        SYS_pwrite64
153 #elif defined(SYS_pwrite)
154 #define SYSIO_SYS_pwrite        SYS_pwrite
155 #endif
156 #if _LARGEFILE64_SOURCE && defined(SYS_fcntl64)
157 #define SYSIO_SYS_fcntl         SYS_fcntl64
158 #elif defined(SYS_fcntl)
159 #define SYSIO_SYS_fcntl         SYS_fcntl
160 #endif
161 #if defined(SYS_fsync)
162 #define SYSIO_SYS_fsync         SYS_fsync
163 #endif
164 #if ALPHA_LINUX && defined(SYS_osf_fdatasync)
165 #define SYSIO_SYS_fdatasync     SYS_osf_fdatasync
166 #elif defined(SYS_fdatasync)
167 #define SYSIO_SYS_fdatasync     SYS_fdatasync
168 #endif
169 #if defined(SYS_chmod)
170 #define SYSIO_SYS_chmod         SYS_chmod
171 #endif
172 #if defined(SYS_fchmod)
173 #define SYSIO_SYS_fchmod        SYS_fchmod
174 #endif
175 #if defined(SYS_chown)
176 #define SYSIO_SYS_chown         SYS_chown
177 #endif
178 #if defined(SYS_fchown)
179 #define SYSIO_SYS_fchown        SYS_fchown
180 #endif
181 #if defined(SYS_umask)
182 #define SYSIO_SYS_umask         SYS_umask
183 #endif
184 #if defined(SYS_mkdir)
185 #define SYSIO_SYS_mkdir         SYS_mkdir
186 #endif
187 #if defined(SYS_rmdir)
188 #define SYSIO_SYS_rmdir         SYS_rmdir
189 #endif
190 #if defined(SYS_getdirentries)
191 #if _LARGEFILE64_SOURCE && defined(SYS_getdirentries64)
192 #define SYSIO_SYS_getdirentries SYS_getdirentries64
193 #elif defined(SYS_getdirentries)
194 #define SYSIO_SYS_getdirentries SYS_getdirentries
195 #endif
196 #endif
197 #if _LARGEFILE64_SOURCE && defined(SYS_getdents64)
198 #define SYSIO_SYS_getdents64    SYS_getdents64
199 #elif defined(SYS_getdents)
200 #define SYSIO_SYS_getdents      SYS_getdents
201 #endif
202 #if defined(SYS_link)
203 #define SYSIO_SYS_link          SYS_link
204 #endif
205 #if defined(SYS_unlink)
206 #define SYSIO_SYS_unlink        SYS_unlink
207 #endif
208 #if defined(SYS_symlink)
209 #define SYSIO_SYS_symlink       SYS_symlink
210 #endif
211 #if defined(SYS_rename)
212 #define SYSIO_SYS_rename        SYS_rename
213 #endif
214 #if defined(SYS_readlink)
215 #define SYSIO_SYS_readlink      SYS_readlink
216 #endif
217 #if defined(SYS_utimes)
218 #define SYSIO_SYS_utimes        SYS_utimes
219 #endif
220 #if defined(SYS_utime)
221 #define SYSIO_SYS_utime         SYS_utime
222 #endif
223 #if defined(SYS_socketcall)
224 #define SYSIO_SYS_socketcall    SYS_socketcall
225 #endif
226 #if defined(SYS_socket)
227 #define SYSIO_SYS_socket        SYS_socket
228 #endif
229 #if defined(SYS_accept)
230 #define SYSIO_SYS_accept        SYS_accept
231 #endif
232 #if defined(SYS_bind)
233 #define SYSIO_SYS_bind          SYS_bind
234 #endif
235 #if defined(SYS_listen)
236 #define SYSIO_SYS_listen        SYS_listen
237 #endif
238 #if defined(SYS_connect)
239 #define SYSIO_SYS_connect       SYS_connect
240 #endif
241 #if defined(SYS_ioctl)
242 #define SYSIO_SYS_ioctl         SYS_ioctl
243 #endif