Whamcloud - gitweb
a87ec8133429826f5606893216a6d1cbf22577b2
[fs/lustre-release.git] / libcfs / include / libcfs / winnt / winnt-types.h
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  * GPL HEADER START
5  *
6  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License version 2 only,
10  * as published by the Free Software Foundation.
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * General Public License version 2 for more details (a copy is included
16  * in the LICENSE file that accompanied this code).
17  *
18  * You should have received a copy of the GNU General Public License
19  * version 2 along with this program; If not, see
20  * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
21  *
22  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
23  * CA 95054 USA or visit www.sun.com if you need additional information or
24  * have any questions.
25  *
26  * GPL HEADER END
27  */
28 /*
29  * Copyright  2008 Sun Microsystems, Inc. All rights reserved
30  * Use is subject to license terms.
31  */
32 /*
33  * This file is part of Lustre, http://www.lustre.org/
34  * Lustre is a trademark of Sun Microsystems, Inc.
35  *
36  * libcfs/include/libcfs/winnt/winnt-types.h
37  *
38  * Basic types definitions
39  */
40
41 #ifndef _WINNT_TYPE_H
42 #define _WINNT_TYPE_H
43
44 #ifdef __KERNEL__
45
46 #include <ntifs.h>
47 #include <windef.h>
48 #include <stdio.h>
49 #include <stdlib.h>
50 #include <stdarg.h>
51
52 #include <tdi.h>
53 #include <tdikrnl.h>
54 #include <tdiinfo.h>
55
56 #else
57
58 #include <ntddk.h>
59 #include <stdio.h>
60 #include <stdlib.h>
61 #include <stdarg.h>
62 #include <time.h>
63 #include <io.h>
64 #include <string.h>
65 #include <assert.h>
66
67 #endif
68
69
70 #define __LITTLE_ENDIAN
71
72 #define inline     __inline
73 #define __inline__ __inline
74
75 typedef unsigned __int8     __u8;
76 typedef signed   __int8     __s8;
77
78 typedef signed   __int64    __s64;
79 typedef unsigned __int64    __u64;
80
81 typedef signed   __int16        __s16;
82 typedef unsigned __int16        __u16;
83
84 typedef signed   __int32        __s32;
85 typedef unsigned __int32        __u32;
86
87 typedef signed   __int64        __s64;
88 typedef unsigned __int64        __u64;
89
90 typedef unsigned long       ULONG;
91
92
93 #if defined(_WIN64)
94     #define long_ptr        __int64
95     #define ulong_ptr       unsigned __int64
96     #define BITS_PER_LONG   (64)
97 #else
98     #define long_ptr        long
99     #define ulong_ptr       unsigned long
100     #define BITS_PER_LONG   (32)
101
102 #endif
103
104 /* bsd */
105 typedef unsigned char           u_char;
106 typedef unsigned short          u_short;
107 typedef unsigned int            u_int;
108 typedef unsigned long           u_long;
109
110 /* sysv */
111 typedef unsigned char           unchar;
112 typedef unsigned short          ushort;
113 typedef unsigned int            uint;
114 typedef unsigned long           ulong;
115
116 #ifndef __BIT_TYPES_DEFINED__
117 #define __BIT_TYPES_DEFINED__
118
119 typedef         __u8            u_int8_t;
120 typedef         __s8            int8_t;
121 typedef         __u16           u_int16_t;
122 typedef         __s16           int16_t;
123 typedef         __u32           u_int32_t;
124 typedef         __s32           int32_t;
125
126 #endif /* !(__BIT_TYPES_DEFINED__) */
127
128 typedef         __u8            uint8_t;
129 typedef         __u16           uint16_t;
130 typedef         __u32           uint32_t;
131
132 typedef         __u64           uint64_t;
133 typedef         __u64           u_int64_t;
134 typedef         __s64           int64_t;
135
136 typedef long            ssize_t;
137
138 typedef __u32           suseconds_t;
139
140 typedef __u32           pid_t, tid_t;
141
142 typedef __u16           uid_t, gid_t;
143
144 typedef __u16           mode_t;
145 typedef __u16           umode_t;
146
147 typedef ulong_ptr       sigset_t;
148
149 typedef uint64_t        loff_t;
150 typedef HANDLE          cfs_handle_t;
151 typedef uint64_t        cycles_t;
152
153 #ifndef INVALID_HANDLE_VALUE
154 #define INVALID_HANDLE_VALUE ((HANDLE)-1)
155 #endif
156
157
158 #ifdef __KERNEL__ /* kernel */
159
160 typedef __u32           off_t;
161 typedef __u32           time_t;
162
163 typedef unsigned short  kdev_t;
164
165 #else  /* !__KERNEL__ */
166
167 typedef int             BOOL;
168 typedef __u8            BYTE;
169 typedef __u16           WORD;
170 typedef __u32           DWORD;
171
172 #endif /* __KERNEL__ */
173
174 /*
175  * Conastants suffix
176  */
177
178 #define ULL i64
179 #define ull i64
180
181 /*
182  * Winnt kernel has no capabilities.
183  */
184
185 typedef __u32 cfs_kernel_cap_t;
186
187 #define INT_MAX         ((int)(~0U>>1))
188 #define INT_MIN         (-INT_MAX - 1)
189 #define UINT_MAX        (~0U)
190
191 #endif /* _WINNT_TYPES_H */
192
193
194 /*
195  *  Bytes order 
196  */
197
198 //
199 // Byte order swapping routines
200 //
201
202
203 #define ___swab16(x) RtlUshortByteSwap(x)
204 #define ___swab32(x) RtlUlongByteSwap(x)
205 #define ___swab64(x) RtlUlonglongByteSwap(x)
206
207 #define ___constant_swab16(x) \
208         ((__u16)( \
209                 (((__u16)(x) & (__u16)0x00ffU) << 8) | \
210                 (((__u16)(x) & (__u16)0xff00U) >> 8) ))
211
212 #define ___constant_swab32(x) \
213         ((__u32)( \
214                 (((__u32)(x) & (__u32)0x000000ffUL) << 24) | \
215                 (((__u32)(x) & (__u32)0x0000ff00UL) <<  8) | \
216                 (((__u32)(x) & (__u32)0x00ff0000UL) >>  8) | \
217                 (((__u32)(x) & (__u32)0xff000000UL) >> 24) ))
218
219 #define ___constant_swab64(x) \
220         ((__u64)( \
221                 (__u64)(((__u64)(x) & (__u64)0x00000000000000ffUL) << 56) | \
222                 (__u64)(((__u64)(x) & (__u64)0x000000000000ff00UL) << 40) | \
223                 (__u64)(((__u64)(x) & (__u64)0x0000000000ff0000UL) << 24) | \
224                 (__u64)(((__u64)(x) & (__u64)0x00000000ff000000UL) <<  8) | \
225                 (__u64)(((__u64)(x) & (__u64)0x000000ff00000000UL) >>  8) | \
226                 (__u64)(((__u64)(x) & (__u64)0x0000ff0000000000UL) >> 24) | \
227                 (__u64)(((__u64)(x) & (__u64)0x00ff000000000000UL) >> 40) | \
228                 (__u64)(((__u64)(x) & (__u64)0xff00000000000000UL) >> 56) ))
229
230
231 #define __swab16(x)  ___constant_swab16(x)
232 #define __swab32(x)  ___constant_swab32(x)
233 #define __swab64(x)  ___constant_swab64(x)
234
235 #define __swab16s(x) do { *(x) = __swab16((USHORT)(*(x)));} while(0)
236 #define __swab32s(x) do { *(x) = __swab32((ULONG)(*(x)));} while(0)
237 #define __swab64s(x) do { *(x) = __swab64((ULONGLONG)(*(x)));} while(0)
238
239 #define __constant_htonl(x) ___constant_swab32((x))
240 #define __constant_ntohl(x) ___constant_swab32((x))
241 #define __constant_htons(x) ___constant_swab16((x))
242 #define __constant_ntohs(x) ___constant_swab16((x))
243 #define __constant_cpu_to_le64(x) ((__u64)(x))
244 #define __constant_le64_to_cpu(x) ((__u64)(x))
245 #define __constant_cpu_to_le32(x) ((__u32)(x))
246 #define __constant_le32_to_cpu(x) ((__u32)(x))
247 #define __constant_cpu_to_le16(x) ((__u16)(x))
248 #define __constant_le16_to_cpu(x) ((__u16)(x))
249 #define __constant_cpu_to_be64(x) ___constant_swab64((x))
250 #define __constant_be64_to_cpu(x) ___constant_swab64((x))
251 #define __constant_cpu_to_be32(x) ___constant_swab32((x))
252 #define __constant_be32_to_cpu(x) ___constant_swab32((x))
253 #define __constant_cpu_to_be16(x) ___constant_swab16((x))
254 #define __constant_be16_to_cpu(x) ___constant_swab16((x))
255 #define __cpu_to_le64(x) ((__u64)(x))
256 #define __le64_to_cpu(x) ((__u64)(x))
257 #define __cpu_to_le32(x) ((__u32)(x))
258 #define __le32_to_cpu(x) ((__u32)(x))
259 #define __cpu_to_le16(x) ((__u16)(x))
260 #define __le16_to_cpu(x) ((__u16)(x))
261 #define __cpu_to_be64(x) __swab64((x))
262 #define __be64_to_cpu(x) __swab64((x))
263 #define __cpu_to_be32(x) __swab32((x))
264 #define __be32_to_cpu(x) __swab32((x))
265 #define __cpu_to_be16(x) __swab16((x))
266 #define __be16_to_cpu(x) __swab16((x))
267 #define __cpu_to_le64p(x) (*(__u64*)(x))
268 #define __le64_to_cpup(x) (*(__u64*)(x))
269 #define __cpu_to_le32p(x) (*(__u32*)(x))
270 #define __le32_to_cpup(x) (*(__u32*)(x))
271 #define __cpu_to_le16p(x) (*(__u16*)(x))
272 #define __le16_to_cpup(x) (*(__u16*)(x))
273 #define __cpu_to_be64p(x) __swab64p((x))
274 #define __be64_to_cpup(x) __swab64p((x))
275 #define __cpu_to_be32p(x) __swab32p((x))
276 #define __be32_to_cpup(x) __swab32p((x))
277 #define __cpu_to_be16p(x) __swab16p((x))
278 #define __be16_to_cpup(x) __swab16p((x))
279 #define __cpu_to_le64s(x) do {} while (0)
280 #define __le64_to_cpus(x) do {} while (0)
281 #define __cpu_to_le32s(x) do {} while (0)
282 #define __le32_to_cpus(x) do {} while (0)
283 #define __cpu_to_le16s(x) do {} while (0)
284 #define __le16_to_cpus(x) do {} while (0)
285 #define __cpu_to_be64s(x) __swab64s((x))
286 #define __be64_to_cpus(x) __swab64s((x))
287 #define __cpu_to_be32s(x) __swab32s((x))
288 #define __be32_to_cpus(x) __swab32s((x))
289 #define __cpu_to_be16s(x) __swab16s((x))
290 #define __be16_to_cpus(x) __swab16s((x))
291
292 #ifndef cpu_to_le64
293 #define cpu_to_le64 __cpu_to_le64
294 #define le64_to_cpu __le64_to_cpu
295 #define cpu_to_le32 __cpu_to_le32
296 #define le32_to_cpu __le32_to_cpu
297 #define cpu_to_le16 __cpu_to_le16
298 #define le16_to_cpu __le16_to_cpu
299 #endif
300
301 #define cpu_to_be64 __cpu_to_be64
302 #define be64_to_cpu __be64_to_cpu
303 #define cpu_to_be32 __cpu_to_be32
304 #define be32_to_cpu __be32_to_cpu
305 #define cpu_to_be16 __cpu_to_be16
306 #define be16_to_cpu __be16_to_cpu
307 #define cpu_to_le64p __cpu_to_le64p
308 #define le64_to_cpup __le64_to_cpup
309 #define cpu_to_le32p __cpu_to_le32p
310 #define le32_to_cpup __le32_to_cpup
311 #define cpu_to_le16p __cpu_to_le16p
312 #define le16_to_cpup __le16_to_cpup
313 #define cpu_to_be64p __cpu_to_be64p
314 #define be64_to_cpup __be64_to_cpup
315 #define cpu_to_be32p __cpu_to_be32p
316 #define be32_to_cpup __be32_to_cpup
317 #define cpu_to_be16p __cpu_to_be16p
318 #define be16_to_cpup __be16_to_cpup
319 #define cpu_to_le64s __cpu_to_le64s
320 #define le64_to_cpus __le64_to_cpus
321 #define cpu_to_le32s __cpu_to_le32s
322 #define le32_to_cpus __le32_to_cpus
323 #define cpu_to_le16s __cpu_to_le16s
324 #define le16_to_cpus __le16_to_cpus
325 #define cpu_to_be64s __cpu_to_be64s
326 #define be64_to_cpus __be64_to_cpus
327 #define cpu_to_be32s __cpu_to_be32s
328 #define be32_to_cpus __be32_to_cpus
329 #define cpu_to_be16s __cpu_to_be16s
330 #define be16_to_cpus __be16_to_cpus
331
332
333 //
334 // Network to host byte swap functions
335 //
336
337 #define ntohl(x)           ( ( ( ( x ) & 0x000000ff ) << 24 ) | \
338                              ( ( ( x ) & 0x0000ff00 ) << 8 ) | \
339                              ( ( ( x ) & 0x00ff0000 ) >> 8 ) | \
340                              ( ( ( x ) & 0xff000000 ) >> 24 )   )
341
342 #define ntohs(x)           ( ( ( ( x ) & 0xff00 ) >> 8 ) | \
343                              ( ( ( x ) & 0x00ff ) << 8 ) )
344
345
346 #define htonl(x)           ntohl(x)
347 #define htons(x)           ntohs(x)
348
349
350
351 #ifndef _I386_ERRNO_H
352 #define _I386_ERRNO_H
353
354 #define EPERM            1      /* Operation not permitted */
355 #define ENOENT           2      /* No such file or directory */
356 #define ESRCH            3      /* No such process */
357 #define EINTR            4      /* Interrupted system call */
358 #define EIO                  5  /* I/O error */
359 #define ENXIO            6      /* No such device or address */
360 #define E2BIG            7      /* Arg list too long */
361 #define ENOEXEC          8      /* Exec format error */
362 #define EBADF            9      /* Bad file number */
363 #define ECHILD          10      /* No child processes */
364 #define EAGAIN          11      /* Try again */
365 #define ENOMEM          12      /* Out of memory */
366 #define EACCES          13      /* Permission denied */
367 #define EFAULT          14      /* Bad address */
368 #define ENOTBLK         15      /* Block device required */
369 #define EBUSY           16      /* Device or resource busy */
370 #define EEXIST          17      /* File exists */
371 #define EXDEV           18      /* Cross-device link */
372 #define ENODEV          19      /* No such device */
373 #define ENOTDIR         20      /* Not a directory */
374 #define EISDIR          21      /* Is a directory */
375 #define EINVAL          22      /* Invalid argument */
376 #define ENFILE          23      /* File table overflow */
377 #define EMFILE          24      /* Too many open files */
378 #define ENOTTY          25      /* Not a typewriter */
379 #define ETXTBSY         26      /* Text file busy */
380 #define EFBIG           27      /* File too large */
381 #define ENOSPC          28      /* No space left on device */
382 #define ESPIPE          29      /* Illegal seek */
383 #define EROFS           30      /* Read-only file system */
384 #define EMLINK          31      /* Too many links */
385 #define EPIPE           32      /* Broken pipe */
386 #define EDOM            33      /* Math argument out of domain of func */
387 #define ERANGE          34      /* Math result not representable */
388 #undef EDEADLK
389 #define EDEADLK         35      /* Resource deadlock would occur */
390 #undef ENAMETOOLONG
391 #define ENAMETOOLONG    36      /* File name too long */
392 #undef ENOLCK
393 #define ENOLCK          37      /* No record locks available */
394 #undef ENOSYS
395 #define ENOSYS          38      /* Function not implemented */
396 #undef ENOTEMPTY
397 #define ENOTEMPTY       39      /* Directory not empty */
398 #define ELOOP           40      /* Too many symbolic links encountered */
399 #define EWOULDBLOCK     EAGAIN  /* Operation would block */
400 #define ENOMSG          42      /* No message of desired type */
401 #define EIDRM           43      /* Identifier removed */
402 #define ECHRNG          44      /* Channel number out of range */
403 #define EL2NSYNC        45      /* Level 2 not synchronized */
404 #define EL3HLT          46      /* Level 3 halted */
405 #define EL3RST          47      /* Level 3 reset */
406 #define ELNRNG          48      /* Link number out of range */
407 #define EUNATCH         49      /* Protocol driver not attached */
408 #define ENOCSI          50      /* No CSI structure available */
409 #define EL2HLT          51      /* Level 2 halted */
410 #define EBADE           52      /* Invalid exchange */
411 #define EBADR           53      /* Invalid request descriptor */
412 #define EXFULL          54      /* Exchange full */
413 #define ENOANO          55      /* No anode */
414 #define EBADRQC         56      /* Invalid request code */
415 #define EBADSLT         57      /* Invalid slot */
416
417 #define EDEADLOCK       EDEADLK
418
419 #define EBFONT          59      /* Bad font file format */
420 #define ENOSTR          60      /* Device not a stream */
421 #define ENODATA         61      /* No data available */
422 #define ETIME           62      /* Timer expired */
423 #define ENOSR           63      /* Out of streams resources */
424 #define ENONET          64      /* Machine is not on the network */
425 #define ENOPKG          65      /* Package not installed */
426 #define EREMOTE         66      /* Object is remote */
427 #define ENOLINK         67      /* Link has been severed */
428 #define EADV            68      /* Advertise error */
429 #define ESRMNT          69      /* Srmount error */
430 #define ECOMM           70      /* Communication error on send */
431 #define EPROTO          71      /* Protocol error */
432 #define EMULTIHOP       72      /* Multihop attempted */
433 #define EDOTDOT         73      /* RFS specific error */
434 #define EBADMSG         74      /* Not a data message */
435 #define EOVERFLOW       75      /* Value too large for defined data type */
436 #define ENOTUNIQ        76      /* Name not unique on network */
437 #define EBADFD          77      /* File descriptor in bad state */
438 #define EREMCHG         78      /* Remote address changed */
439 #define ELIBACC         79      /* Can not access a needed shared library */
440 #define ELIBBAD         80      /* Accessing a corrupted shared library */
441 #define ELIBSCN         81      /* .lib section in a.out corrupted */
442 #define ELIBMAX         82      /* Attempting to link in too many shared libraries */
443 #define ELIBEXEC        83      /* Cannot exec a shared library directly */
444 #undef EILSEQ
445 #define EILSEQ          84      /* Illegal byte sequence */
446 #define ERESTART        85      /* Interrupted system call should be restarted */
447 #define ESTRPIPE        86      /* Streams pipe error */
448 #define EUSERS          87      /* Too many users */
449 #define ENOTSOCK        88      /* Socket operation on non-socket */
450 #define EDESTADDRREQ    89      /* Destination address required */
451 #define EMSGSIZE        90      /* Message too long */
452 #define EPROTOTYPE      91      /* Protocol wrong type for socket */
453 #define ENOPROTOOPT     92      /* Protocol not available */
454 #define EPROTONOSUPPORT 93      /* Protocol not supported */
455 #define ESOCKTNOSUPPORT 94      /* Socket type not supported */
456 #define EOPNOTSUPP      95      /* Operation not supported on transport endpoint */
457 #define EPFNOSUPPORT    96      /* Protocol family not supported */
458 #define EAFNOSUPPORT    97      /* Address family not supported by protocol */
459 #define EADDRINUSE      98      /* Address already in use */
460 #define EADDRNOTAVAIL   99      /* Cannot assign requested address */
461 #define ENETDOWN        100     /* Network is down */
462 #define ENETUNREACH     101     /* Network is unreachable */
463 #define ENETRESET       102     /* Network dropped connection because of reset */
464 #define ECONNABORTED    103     /* Software caused connection abort */
465 #define ECONNRESET      104     /* Connection reset by peer */
466 #define ENOBUFS         105     /* No buffer space available */
467 #define EISCONN         106     /* Transport endpoint is already connected */
468 #define ENOTCONN        107     /* Transport endpoint is not connected */
469 #define ESHUTDOWN       108     /* Cannot send after transport endpoint shutdown */
470 #define ETOOMANYREFS    109     /* Too many references: cannot splice */
471 #define ETIMEDOUT       110     /* Connection timed out */
472 #define ECONNREFUSED    111     /* Connection refused */
473 #define EHOSTDOWN       112     /* Host is down */
474 #define EHOSTUNREACH    113     /* No route to host */
475 #define EALREADY        114     /* Operation already in progress */
476 #define EINPROGRESS     115     /* Operation now in progress */
477 #define ESTALE          116     /* Stale NFS file handle */
478 #define EUCLEAN         117     /* Structure needs cleaning */
479 #define ENOTNAM         118     /* Not a XENIX named type file */
480 #define ENAVAIL         119     /* No XENIX semaphores available */
481 #define EISNAM          120     /* Is a named type file */
482 #define EREMOTEIO       121     /* Remote I/O error */
483 #define EDQUOT          122     /* Quota exceeded */
484
485 #define ENOMEDIUM       123     /* No medium found */
486 #define EMEDIUMTYPE     124     /* Wrong medium type */
487
488 /* Should never be seen by user programs */
489 #define ERESTARTSYS     512
490 #define ERESTARTNOINTR  513
491 #define ERESTARTNOHAND  514     /* restart if no handler.. */
492 #define ENOIOCTLCMD     515     /* No ioctl command */
493
494 /* Defined for the NFSv3 protocol */
495 #define EBADHANDLE      521     /* Illegal NFS file handle */
496 #define ENOTSYNC        522     /* Update synchronization mismatch */
497 #define EBADCOOKIE      523     /* Cookie is stale */
498 #define ENOTSUPP        524     /* Operation is not supported */
499 #define ETOOSMALL       525     /* Buffer or request is too small */
500 #define ESERVERFAULT    526     /* An untranslatable error occurred */
501 #define EBADTYPE        527     /* Type not supported by server */
502 #define EJUKEBOX        528     /* Request initiated, but will not complete before timeout */
503
504
505
506 /* open/fcntl - O_SYNC is only implemented on blocks devices and on files
507    located on an ext2 file system */
508 #define O_ACCMODE          0003
509 #define O_RDONLY             00
510 #define O_WRONLY             01
511 #define O_RDWR               02
512 #define O_CREAT            0100 /* not fcntl */
513 #define O_EXCL             0200 /* not fcntl */
514 #define O_NOCTTY           0400 /* not fcntl */
515 #define O_TRUNC           01000 /* not fcntl */
516 #define O_APPEND          02000
517 #define O_NONBLOCK        04000
518 #define O_NDELAY        O_NONBLOCK
519 #define O_SYNC           010000
520 #define FASYNC           020000 /* fcntl, for BSD compatibility */
521 #define O_DIRECT         040000 /* direct disk access hint */
522 #define O_LARGEFILE     0100000
523 #define O_DIRECTORY     0200000 /* must be a directory */
524 #define O_NOFOLLOW      0400000 /* don't follow links */
525
526 #define F_DUPFD         0       /* dup */
527 #define F_GETFD         1       /* get close_on_exec */
528 #define F_SETFD         2       /* set/clear close_on_exec */
529 #define F_GETFL         3       /* get file->f_flags */
530 #define F_SETFL         4       /* set file->f_flags */
531 #define F_GETLK         5
532 #define F_SETLK         6
533 #define F_SETLKW        7
534
535 #define F_SETOWN        8       /*  for sockets. */
536 #define F_GETOWN        9       /*  for sockets. */
537 #define F_SETSIG        10      /*  for sockets. */
538 #define F_GETSIG        11      /*  for sockets. */
539
540 #define F_GETLK64       12      /*  using 'struct flock64' */
541 #define F_SETLK64       13
542 #define F_SETLKW64      14
543
544 /* for F_[GET|SET]FL */
545 #define FD_CLOEXEC      1       /* actually anything with low bit set goes */
546
547 /* for posix fcntl() and lockf() */
548 #define F_RDLCK         0
549 #define F_WRLCK         1
550 #define F_UNLCK         2
551
552 /* for old implementation of bsd flock () */
553 #define F_EXLCK         4       /* or 3 */
554 #define F_SHLCK         8       /* or 4 */
555
556 /* for leases */
557 #define F_INPROGRESS    16
558
559 /* operations for bsd flock(), also used by the kernel implementation */
560 #define LOCK_SH         1       /* shared lock */
561 #define LOCK_EX         2       /* exclusive lock */
562 #define LOCK_NB         4       /* or'd with one of the above to prevent
563                                    blocking */
564 #define LOCK_UN         8       /* remove lock */
565
566 #define LOCK_MAND       32      /* This is a mandatory flock */
567 #define LOCK_READ       64      /* ... Which allows concurrent read operations */
568 #define LOCK_WRITE      128     /* ... Which allows concurrent write operations */
569 #define LOCK_RW         192     /* ... Which allows concurrent read & write ops */
570
571 #endif
572
573
574 #ifndef LIBCFS_SIGNAL_H
575 #define LIBCFS_SIGNAL_H
576
577 /*
578  *  signal values ...
579  */
580
581 #define SIGHUP           1
582 #define SIGINT           2
583 #define SIGQUIT          3
584 #define SIGILL           4
585 #define SIGTRAP          5
586 #define SIGABRT          6
587 #define SIGIOT           6
588 #define SIGBUS           7
589 #define SIGFPE           8
590 #define SIGKILL          9
591 #define SIGUSR1         10
592 #define SIGSEGV         11
593 #define SIGUSR2         12
594 #define SIGPIPE         13
595 #define SIGALRM         14
596 #define SIGTERM         15
597 #define SIGSTKFLT       16
598 #define SIGCHLD         17
599 #define SIGCONT         18
600 #define SIGSTOP         19
601 #define SIGTSTP         20
602 #define SIGTTIN         21
603 #define SIGTTOU         22
604 #define SIGURG          23
605 #define SIGXCPU         24
606 #define SIGXFSZ         25
607 #define SIGVTALRM       26
608 #define SIGPROF         27
609 #define SIGWINCH        28
610 #define SIGIO           29
611 #define SIGPOLL         SIGIO
612 /*
613 #define SIGLOST         29
614 */
615 #define SIGPWR          30
616 #define SIGSYS          31
617 #define SIGUNUSED       31
618
619 /* These should not be considered constants from userland.  */
620 #define SIGRTMIN        32
621 #define SIGRTMAX        (_NSIG-1)
622
623 /*
624  * SA_FLAGS values:
625  *
626  * SA_ONSTACK indicates that a registered stack_t will be used.
627  * SA_INTERRUPT is a no-op, but left due to historical reasons. Use the
628  * SA_RESTART flag to get restarting signals (which were the default long ago)
629  * SA_NOCLDSTOP flag to turn off SIGCHLD when children stop.
630  * SA_RESETHAND clears the handler when the signal is delivered.
631  * SA_NOCLDWAIT flag on SIGCHLD to inhibit zombies.
632  * SA_NODEFER prevents the current signal from being masked in the handler.
633  *
634  * SA_ONESHOT and SA_NOMASK are the historical Linux names for the Single
635  * Unix names RESETHAND and NODEFER respectively.
636  */
637 #define SA_NOCLDSTOP    0x00000001
638 #define SA_NOCLDWAIT    0x00000002 /* not supported yet */
639 #define SA_SIGINFO      0x00000004
640 #define SA_ONSTACK      0x08000000
641 #define SA_RESTART      0x10000000
642 #define SA_NODEFER      0x40000000
643 #define SA_RESETHAND    0x80000000
644
645 #define SA_NOMASK       SA_NODEFER
646 #define SA_ONESHOT      SA_RESETHAND
647 #define SA_INTERRUPT    0x20000000 /* dummy -- ignored */
648
649 #define SA_RESTORER     0x04000000
650
651 /* 
652  * sigaltstack controls
653  */
654 #define SS_ONSTACK      1
655 #define SS_DISABLE      2
656
657 #define MINSIGSTKSZ     2048
658 #define SIGSTKSZ        8192
659
660
661 #define sigmask(sig)   ((__u32)1 << ((sig) - 1))
662
663 #endif // LIBCFS_SIGNAL_H