4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
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.
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).
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
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
27 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
28 * Use is subject to license terms.
31 * This file is part of Lustre, http://www.lustre.org/
32 * Lustre is a trademark of Sun Microsystems, Inc.
34 * libcfs/include/libcfs/winnt/winnt-types.h
36 * Basic types definitions
67 #define __LITTLE_ENDIAN
70 #define inline __inline
71 #define __inline__ __inline
73 typedef unsigned __int8 __u8;
74 typedef signed __int8 __s8;
76 typedef signed __int16 __s16;
77 typedef unsigned __int16 __u16;
79 typedef signed __int32 __s32;
80 typedef unsigned __int32 __u32;
82 typedef signed __int64 __s64;
83 typedef unsigned __int64 __u64;
85 typedef unsigned long ULONG;
88 typedef unsigned char u_char;
89 typedef unsigned short u_short;
90 typedef unsigned int u_int;
91 typedef unsigned long u_long;
94 typedef unsigned char unchar;
95 typedef unsigned short ushort;
96 typedef unsigned int uint;
97 typedef unsigned long ulong;
99 #ifndef __BIT_TYPES_DEFINED__
100 #define __BIT_TYPES_DEFINED__
102 typedef __u8 u_int8_t;
104 typedef __u16 u_int16_t;
105 typedef __s16 int16_t;
106 typedef __u32 u_int32_t;
107 typedef __s32 int32_t;
114 #endif /* !(__BIT_TYPES_DEFINED__) */
116 typedef __u8 uint8_t;
117 typedef __u16 uint16_t;
118 typedef __u32 uint32_t;
120 typedef __u64 uint64_t;
121 typedef __u64 u_int64_t;
122 typedef __s64 int64_t;
124 typedef long ssize_t;
126 typedef __u32 suseconds_t;
128 typedef __u16 uid_t, gid_t;
130 typedef __u16 mode_t;
131 typedef __u16 cfs_umode_t;
133 typedef __u32 sigset_t;
135 typedef int64_t loff_t;
136 typedef void * cfs_handle_t;
137 typedef uint64_t cfs_cycles_t;
139 #ifndef INVALID_HANDLE_VALUE
140 #define INVALID_HANDLE_VALUE ((HANDLE)-1)
143 # define BITS_PER_LONG (32)
146 typedef __int64 long_ptr_t;
147 typedef unsigned __int64 ulong_ptr_t;
149 typedef long long_ptr_t;
150 typedef unsigned long ulong_ptr_t;
153 #ifdef __KERNEL__ /* kernel */
162 #define dma_addr_t PVOID
170 // Byte order swapping routines
173 #if 0 && NTDDI_VERSION < 0x06000000
189 RtlUlonglongByteSwap(
194 #else /* !__KERNEL__ */
204 #define __WORDSIZE 32
207 #endif /* __KERNEL__ */
216 #define ___swab16(x) RtlUshortByteSwap(x)
217 #define ___swab32(x) RtlUlongByteSwap(x)
218 #define ___swab64(x) RtlUlonglongByteSwap(x)
220 #define ___constant_swab16(x) \
222 (((__u16)(x) & (__u16)0x00ffU) << 8) | \
223 (((__u16)(x) & (__u16)0xff00U) >> 8) ))
225 #define ___constant_swab32(x) \
227 (((__u32)(x) & (__u32)0x000000ffUL) << 24) | \
228 (((__u32)(x) & (__u32)0x0000ff00UL) << 8) | \
229 (((__u32)(x) & (__u32)0x00ff0000UL) >> 8) | \
230 (((__u32)(x) & (__u32)0xff000000UL) >> 24) ))
232 #define ___constant_swab64(x) \
234 (__u64)(((__u64)(x) & (__u64)0x00000000000000ffUi64) << 56) | \
235 (__u64)(((__u64)(x) & (__u64)0x000000000000ff00Ui64) << 40) | \
236 (__u64)(((__u64)(x) & (__u64)0x0000000000ff0000Ui64) << 24) | \
237 (__u64)(((__u64)(x) & (__u64)0x00000000ff000000Ui64) << 8) | \
238 (__u64)(((__u64)(x) & (__u64)0x000000ff00000000Ui64) >> 8) | \
239 (__u64)(((__u64)(x) & (__u64)0x0000ff0000000000Ui64) >> 24) | \
240 (__u64)(((__u64)(x) & (__u64)0x00ff000000000000Ui64) >> 40) | \
241 (__u64)(((__u64)(x) & (__u64)0xff00000000000000Ui64) >> 56) ))
244 #define __swab16(x) ___constant_swab16(x)
245 #define __swab32(x) ___constant_swab32(x)
246 #define __swab64(x) ___constant_swab64(x)
248 #define __swab16s(x) do { *(x) = __swab16((USHORT)(*(x)));} while(0)
249 #define __swab32s(x) do { *(x) = __swab32((ULONG)(*(x)));} while(0)
250 #define __swab64s(x) do { *(x) = __swab64((ULONGLONG)(*(x)));} while(0)
252 #define __constant_htonl(x) ___constant_swab32((x))
253 #define __constant_ntohl(x) ___constant_swab32((x))
254 #define __constant_htons(x) ___constant_swab16((x))
255 #define __constant_ntohs(x) ___constant_swab16((x))
256 #define __constant_cpu_to_le64(x) ((__u64)(x))
257 #define __constant_le64_to_cpu(x) ((__u64)(x))
258 #define __constant_cpu_to_le32(x) ((__u32)(x))
259 #define __constant_le32_to_cpu(x) ((__u32)(x))
260 #define __constant_cpu_to_le16(x) ((__u16)(x))
261 #define __constant_le16_to_cpu(x) ((__u16)(x))
262 #define __constant_cpu_to_be64(x) ___constant_swab64((x))
263 #define __constant_be64_to_cpu(x) ___constant_swab64((x))
264 #define __constant_cpu_to_be32(x) ___constant_swab32((x))
265 #define __constant_be32_to_cpu(x) ___constant_swab32((x))
266 #define __constant_cpu_to_be16(x) ___constant_swab16((x))
267 #define __constant_be16_to_cpu(x) ___constant_swab16((x))
268 #define __cpu_to_le64(x) ((__u64)(x))
269 #define __le64_to_cpu(x) ((__u64)(x))
270 #define __cpu_to_le32(x) ((__u32)(x))
271 #define __le32_to_cpu(x) ((__u32)(x))
272 #define __cpu_to_le16(x) ((__u16)(x))
273 #define __le16_to_cpu(x) ((__u16)(x))
274 #define __cpu_to_be64(x) __swab64((x))
275 #define __be64_to_cpu(x) __swab64((x))
276 #define __cpu_to_be32(x) __swab32((x))
277 #define __be32_to_cpu(x) __swab32((x))
278 #define __cpu_to_be16(x) __swab16((x))
279 #define __be16_to_cpu(x) __swab16((x))
280 #define __cpu_to_le64p(x) (*(__u64*)(x))
281 #define __le64_to_cpup(x) (*(__u64*)(x))
282 #define __cpu_to_le32p(x) (*(__u32*)(x))
283 #define __le32_to_cpup(x) (*(__u32*)(x))
284 #define __cpu_to_le16p(x) (*(__u16*)(x))
285 #define __le16_to_cpup(x) (*(__u16*)(x))
286 #define __cpu_to_be64p(x) __swab64p((x))
287 #define __be64_to_cpup(x) __swab64p((x))
288 #define __cpu_to_be32p(x) __swab32p((x))
289 #define __be32_to_cpup(x) __swab32p((x))
290 #define __cpu_to_be16p(x) __swab16p((x))
291 #define __be16_to_cpup(x) __swab16p((x))
292 #define __cpu_to_le64s(x) do {} while (0)
293 #define __le64_to_cpus(x) do {} while (0)
294 #define __cpu_to_le32s(x) do {} while (0)
295 #define __le32_to_cpus(x) do {} while (0)
296 #define __cpu_to_le16s(x) do {} while (0)
297 #define __le16_to_cpus(x) do {} while (0)
298 #define __cpu_to_be64s(x) __swab64s((x))
299 #define __be64_to_cpus(x) __swab64s((x))
300 #define __cpu_to_be32s(x) __swab32s((x))
301 #define __be32_to_cpus(x) __swab32s((x))
302 #define __cpu_to_be16s(x) __swab16s((x))
303 #define __be16_to_cpus(x) __swab16s((x))
306 #define cpu_to_le64 __cpu_to_le64
307 #define le64_to_cpu __le64_to_cpu
308 #define cpu_to_le32 __cpu_to_le32
309 #define le32_to_cpu __le32_to_cpu
310 #define cpu_to_le16 __cpu_to_le16
311 #define le16_to_cpu __le16_to_cpu
314 #define cpu_to_be64 __cpu_to_be64
315 #define be64_to_cpu __be64_to_cpu
316 #define cpu_to_be32 __cpu_to_be32
317 #define be32_to_cpu __be32_to_cpu
318 #define cpu_to_be16 __cpu_to_be16
319 #define be16_to_cpu __be16_to_cpu
320 #define cpu_to_le64p __cpu_to_le64p
321 #define le64_to_cpup __le64_to_cpup
322 #define cpu_to_le32p __cpu_to_le32p
323 #define le32_to_cpup __le32_to_cpup
324 #define cpu_to_le16p __cpu_to_le16p
325 #define le16_to_cpup __le16_to_cpup
326 #define cpu_to_be64p __cpu_to_be64p
327 #define be64_to_cpup __be64_to_cpup
328 #define cpu_to_be32p __cpu_to_be32p
329 #define be32_to_cpup __be32_to_cpup
330 #define cpu_to_be16p __cpu_to_be16p
331 #define be16_to_cpup __be16_to_cpup
332 #define cpu_to_le64s __cpu_to_le64s
333 #define le64_to_cpus __le64_to_cpus
334 #define cpu_to_le32s __cpu_to_le32s
335 #define le32_to_cpus __le32_to_cpus
336 #define cpu_to_le16s __cpu_to_le16s
337 #define le16_to_cpus __le16_to_cpus
338 #define cpu_to_be64s __cpu_to_be64s
339 #define be64_to_cpus __be64_to_cpus
340 #define cpu_to_be32s __cpu_to_be32s
341 #define be32_to_cpus __be32_to_cpus
342 #define cpu_to_be16s __cpu_to_be16s
343 #define be16_to_cpus __be16_to_cpus
347 // Network to host byte swap functions
350 #define ntohl(x) ( ( ( ( x ) & 0x000000ff ) << 24 ) | \
351 ( ( ( x ) & 0x0000ff00 ) << 8 ) | \
352 ( ( ( x ) & 0x00ff0000 ) >> 8 ) | \
353 ( ( ( x ) & 0xff000000 ) >> 24 ) )
355 #define ntohs(x) ( ( ( ( x ) & 0xff00 ) >> 8 ) | \
356 ( ( ( x ) & 0x00ff ) << 8 ) )
359 #define htonl(x) ntohl(x)
360 #define htons(x) ntohs(x)
364 * array must be used for array not pointer
366 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
368 #endif /* _WINNT_TYPES_H */
370 #ifndef _I386_ERRNO_H
371 #define _I386_ERRNO_H
375 #define EPERM 1 /* Operation not permitted */
376 #define ENOENT 2 /* No such file or directory */
377 #define ESRCH 3 /* No such process */
378 #define EINTR 4 /* Interrupted system call */
379 #define EIO 5 /* I/O error */
380 #define ENXIO 6 /* No such device or address */
381 #define E2BIG 7 /* Arg list too long */
382 #define ENOEXEC 8 /* Exec format error */
383 #define EBADF 9 /* Bad file number */
384 #define ECHILD 10 /* No child processes */
385 #define EAGAIN 11 /* Try again */
386 #define ENOMEM 12 /* Out of memory */
387 #define EACCES 13 /* Permission denied */
388 #define EFAULT 14 /* Bad address */
389 #define ENOTBLK 15 /* Block device required */
390 #define EBUSY 16 /* Device or resource busy */
391 #define EEXIST 17 /* File exists */
392 #define EXDEV 18 /* Cross-device link */
393 #define ENODEV 19 /* No such device */
394 #define ENOTDIR 20 /* Not a directory */
395 #define EISDIR 21 /* Is a directory */
396 #define EINVAL 22 /* Invalid argument */
397 #define ENFILE 23 /* File table overflow */
398 #define EMFILE 24 /* Too many open files */
399 #define ENOTTY 25 /* Not a typewriter */
400 #define ETXTBSY 26 /* Text file busy */
401 #define EFBIG 27 /* File too large */
402 #define ENOSPC 28 /* No space left on device */
403 #define ESPIPE 29 /* Illegal seek */
404 #define EROFS 30 /* Read-only file system */
405 #define EMLINK 31 /* Too many links */
406 #define EPIPE 32 /* Broken pipe */
407 #define EDOM 33 /* Math argument out of domain of func */
408 #define ERANGE 34 /* Math result not representable */
409 #define ELOOP 40 /* Too many symbolic links encountered */
410 #define EWOULDBLOCK EAGAIN /* Operation would block */
411 #define ENOMSG 42 /* No message of desired type */
412 #define EIDRM 43 /* Identifier removed */
413 #define ECHRNG 44 /* Channel number out of range */
414 #define EL2NSYNC 45 /* Level 2 not synchronized */
415 #define EL3HLT 46 /* Level 3 halted */
416 #define EL3RST 47 /* Level 3 reset */
417 #define ELNRNG 48 /* Link number out of range */
418 #define EUNATCH 49 /* Protocol driver not attached */
419 #define ENOCSI 50 /* No CSI structure available */
420 #define EL2HLT 51 /* Level 2 halted */
421 #define EBADE 52 /* Invalid exchange */
422 #define EBADR 53 /* Invalid request descriptor */
423 #define EXFULL 54 /* Exchange full */
424 #define ENOANO 55 /* No anode */
425 #define EBADRQC 56 /* Invalid request code */
426 #define EBADSLT 57 /* Invalid slot */
428 #define EDEADLOCK EDEADLK
430 #define EBFONT 59 /* Bad font file format */
431 #define ENOSTR 60 /* Device not a stream */
432 #define ENODATA 61 /* No data available */
433 #define ETIME 62 /* Timer expired */
434 #define ENOSR 63 /* Out of streams resources */
435 #define ENONET 64 /* Machine is not on the network */
436 #define ENOPKG 65 /* Package not installed */
437 #define EREMOTE 66 /* Object is remote */
438 #define ENOLINK 67 /* Link has been severed */
439 #define EADV 68 /* Advertise error */
440 #define ESRMNT 69 /* Srmount error */
441 #define ECOMM 70 /* Communication error on send */
442 #define EPROTO 71 /* Protocol error */
443 #define EMULTIHOP 72 /* Multihop attempted */
444 #define EDOTDOT 73 /* RFS specific error */
445 #define EBADMSG 74 /* Not a data message */
446 #define EOVERFLOW 75 /* Value too large for defined data type */
447 #define ENOTUNIQ 76 /* Name not unique on network */
448 #define EBADFD 77 /* File descriptor in bad state */
449 #define EREMCHG 78 /* Remote address changed */
450 #define ELIBACC 79 /* Can not access a needed shared library */
451 #define ELIBBAD 80 /* Accessing a corrupted shared library */
452 #define ELIBSCN 81 /* .lib section in a.out corrupted */
453 #define ELIBMAX 82 /* Attempting to link in too many shared libraries */
454 #define ELIBEXEC 83 /* Cannot exec a shared library directly */
455 #define ERESTART 85 /* Interrupted system call should be restarted */
456 #define ESTRPIPE 86 /* Streams pipe error */
457 #define EUSERS 87 /* Too many users */
458 #define ENOTSOCK 88 /* Socket operation on non-socket */
459 #define EDESTADDRREQ 89 /* Destination address required */
460 #define EMSGSIZE 90 /* Message too long */
461 #define EPROTOTYPE 91 /* Protocol wrong type for socket */
462 #define ENOPROTOOPT 92 /* Protocol not available */
463 #define EPROTONOSUPPORT 93 /* Protocol not supported */
464 #define ESOCKTNOSUPPORT 94 /* Socket type not supported */
465 #define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */
466 #define EPFNOSUPPORT 96 /* Protocol family not supported */
467 #define EAFNOSUPPORT 97 /* Address family not supported by protocol */
468 #define EADDRINUSE 98 /* Address already in use */
469 #define EADDRNOTAVAIL 99 /* Cannot assign requested address */
470 #define ENETDOWN 100 /* Network is down */
471 #define ENETUNREACH 101 /* Network is unreachable */
472 #define ENETRESET 102 /* Network dropped connection because of reset */
473 #define ECONNABORTED 103 /* Software caused connection abort */
474 #define ECONNRESET 104 /* Connection reset by peer */
475 #define ENOBUFS 105 /* No buffer space available */
476 #define EISCONN 106 /* Transport endpoint is already connected */
477 #define ENOTCONN 107 /* Transport endpoint is not connected */
478 #define ESHUTDOWN 108 /* Cannot send after transport endpoint shutdown */
479 #define ETOOMANYREFS 109 /* Too many references: cannot splice */
480 #define ETIMEDOUT 110 /* Connection timed out */
481 #define ECONNREFUSED 111 /* Connection refused */
482 #define EHOSTDOWN 112 /* Host is down */
483 #define EHOSTUNREACH 113 /* No route to host */
484 #define EALREADY 114 /* Operation already in progress */
485 #define EINPROGRESS 115 /* Operation now in progress */
486 #define ESTALE 116 /* Stale NFS file handle */
487 #define EUCLEAN 117 /* Structure needs cleaning */
488 #define ENOTNAM 118 /* Not a XENIX named type file */
489 #define ENAVAIL 119 /* No XENIX semaphores available */
490 #define EISNAM 120 /* Is a named type file */
491 #define EREMOTEIO 121 /* Remote I/O error */
492 #define EDQUOT 122 /* Quota exceeded */
494 #define ENOMEDIUM 123 /* No medium found */
495 #define EMEDIUMTYPE 124 /* Wrong medium type */
497 /* Should never be seen by user programs */
498 #define ERESTARTSYS 512
499 #define ERESTARTNOINTR 513
500 #define ERESTARTNOHAND 514 /* restart if no handler.. */
501 #define ENOIOCTLCMD 515 /* No ioctl command */
503 /* Defined for the NFSv3 protocol */
504 #define EBADHANDLE 521 /* Illegal NFS file handle */
505 #define ENOTSYNC 522 /* Update synchronization mismatch */
506 #define EBADCOOKIE 523 /* Cookie is stale */
507 #define ENOTSUPP 524 /* Operation is not supported */
508 #define ETOOSMALL 525 /* Buffer or request is too small */
509 #define ESERVERFAULT 526 /* An untranslatable error occurred */
510 #define EBADTYPE 527 /* Type not supported by server */
511 #define EJUKEBOX 528 /* Request initiated, but will not complete before timeout */
513 /* open/fcntl - O_SYNC is only implemented on blocks devices and on files
514 located on an ext2 file system */
515 #define O_ACCMODE 0003
519 #define O_CREAT 0100 /* not fcntl */
520 #define O_EXCL 0200 /* not fcntl */
521 #define O_NOCTTY 0400 /* not fcntl */
522 #define O_TRUNC 01000 /* not fcntl */
523 #define O_APPEND 02000
524 #define O_NONBLOCK 04000
525 #define O_NDELAY O_NONBLOCK
526 #define O_SYNC 010000
527 #define FASYNC 020000 /* fcntl, for BSD compatibility */
528 #define O_DIRECT 040000 /* direct disk access hint */
529 #define O_LARGEFILE 0100000
530 #define O_DIRECTORY 0200000 /* must be a directory */
531 #define O_NOFOLLOW 0400000 /* don't follow links */
533 #define F_DUPFD 0 /* dup */
534 #define F_GETFD 1 /* get close_on_exec */
535 #define F_SETFD 2 /* set/clear close_on_exec */
536 #define F_GETFL 3 /* get file->f_flags */
537 #define F_SETFL 4 /* set file->f_flags */
542 #define F_SETOWN 8 /* for sockets. */
543 #define F_GETOWN 9 /* for sockets. */
544 #define F_SETSIG 10 /* for sockets. */
545 #define F_GETSIG 11 /* for sockets. */
547 #define F_GETLK64 12 /* using 'struct flock64' */
549 #define F_SETLKW64 14
551 /* for F_[GET|SET]FL */
552 #define FD_CLOEXEC 1 /* actually anything with low bit set goes */
554 /* for posix fcntl() and lockf() */
559 /* for old implementation of bsd flock () */
560 #define F_EXLCK 4 /* or 3 */
561 #define F_SHLCK 8 /* or 4 */
564 #define F_INPROGRESS 16
566 /* operations for bsd flock(), also used by the kernel implementation */
567 #define LOCK_SH 1 /* shared lock */
568 #define LOCK_EX 2 /* exclusive lock */
569 #define LOCK_NB 4 /* or'd with one of the above to prevent
571 #define LOCK_UN 8 /* remove lock */
573 #define LOCK_MAND 32 /* This is a mandatory flock */
574 #define LOCK_READ 64 /* ... Which allows concurrent read operations */
575 #define LOCK_WRITE 128 /* ... Which allows concurrent write operations */
576 #define LOCK_RW 192 /* ... Which allows concurrent read & write ops */
581 #ifndef LIBCFS_SIGNAL_H
582 #define LIBCFS_SIGNAL_H
619 #define SIGPOLL SIGIO
627 /* These should not be considered constants from userland. */
629 #define SIGRTMAX (_NSIG-1)
636 * SA_ONSTACK indicates that a registered stack_t will be used.
637 * SA_INTERRUPT is a no-op, but left due to historical reasons. Use the
638 * SA_RESTART flag to get restarting signals (which were the default long ago)
639 * SA_NOCLDSTOP flag to turn off SIGCHLD when children stop.
640 * SA_RESETHAND clears the handler when the signal is delivered.
641 * SA_NOCLDWAIT flag on SIGCHLD to inhibit zombies.
642 * SA_NODEFER prevents the current signal from being masked in the handler.
644 * SA_ONESHOT and SA_NOMASK are the historical Linux names for the Single
645 * Unix names RESETHAND and NODEFER respectively.
647 #define SA_NOCLDSTOP 0x00000001
648 #define SA_NOCLDWAIT 0x00000002 /* not supported yet */
649 #define SA_SIGINFO 0x00000004
650 #define SA_ONSTACK 0x08000000
651 #define SA_RESTART 0x10000000
652 #define SA_NODEFER 0x40000000
653 #define SA_RESETHAND 0x80000000
655 #define SA_NOMASK SA_NODEFER
656 #define SA_ONESHOT SA_RESETHAND
657 #define SA_INTERRUPT 0x20000000 /* dummy -- ignored */
659 #define SA_RESTORER 0x04000000
662 * sigaltstack controls
667 #define MINSIGSTKSZ 2048
668 #define SIGSTKSZ 8192
671 #define sigmask(sig) ((__u32)1 << ((sig) - 1))
673 #endif // LIBCFS_SIGNAL_H