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