sys/fs/zfs.h: replace grub in comments.
[unleashed.git] / include / sys / types.h
blob06a0443b0de2491f35bc95220c3a43c69bd7a8df
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
19 * CDDL HEADER END
21 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
22 /* All Rights Reserved */
26 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
27 * Use is subject to license terms.
29 * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
32 #ifndef _SYS_TYPES_H
33 #define _SYS_TYPES_H
35 #include <sys/feature_tests.h>
36 #include <sys/isa_defs.h>
39 * Machine dependent definitions moved to <sys/machtypes.h>.
41 #include <sys/machtypes.h>
44 * Include fixed width type declarations proposed by the ISO/JTC1/SC22/WG14 C
45 * committee's working draft for the revision of the current ISO C standard,
46 * ISO/IEC 9899:1990 Programming language - C. These are not currently
47 * required by any standard but constitute a useful, general purpose set
48 * of type definitions which is namespace clean with respect to all standards.
50 #ifdef _KERNEL
51 #include <sys/inttypes.h>
52 #else /* _KERNEL */
53 #include <sys/int_types.h>
54 #endif /* _KERNEL */
56 #if defined(_KERNEL) || defined(_SYSCALL32)
57 #include <sys/types32.h>
58 #endif
60 #ifdef __cplusplus
61 extern "C" {
62 #endif
65 * Strictly conforming ANSI C environments prior to the 1999
66 * revision of the C Standard (ISO/IEC 9899:1999) do not have
67 * the long long data type.
69 #if defined(_LONGLONG_TYPE)
70 typedef long long longlong_t;
71 typedef unsigned long long u_longlong_t;
72 #else
73 /* used to reserve space and generate alignment */
74 typedef union {
75 double _d;
76 int32_t _l[2];
77 } longlong_t;
78 typedef union {
79 double _d;
80 uint32_t _l[2];
81 } u_longlong_t;
82 #endif /* defined(_LONGLONG_TYPE) */
85 * These types (t_{u}scalar_t) exist because the XTI/TPI/DLPI standards had
86 * to use them instead of int32_t and uint32_t because DEC had
87 * shipped 64-bit wide.
89 #if defined(_LP64) || defined(_I32LPx)
90 typedef int32_t t_scalar_t;
91 typedef uint32_t t_uscalar_t;
92 #else
93 typedef long t_scalar_t; /* historical versions */
94 typedef unsigned long t_uscalar_t;
95 #endif /* defined(_LP64) || defined(_I32LPx) */
98 * POSIX Extensions
100 typedef unsigned char uchar_t;
101 typedef unsigned short ushort_t;
102 typedef unsigned int uint_t;
103 typedef unsigned long ulong_t;
105 typedef char *caddr_t; /* ?<core address> type */
106 typedef long daddr_t; /* <disk address> type */
107 typedef short cnt_t; /* ?<count> type */
109 #if !defined(_PTRDIFF_T) || __cplusplus >= 199711L
110 #define _PTRDIFF_T
111 #if defined(_LP64) || defined(_I32LPx)
112 typedef long ptrdiff_t; /* pointer difference */
113 #else
114 typedef int ptrdiff_t; /* (historical version) */
115 #endif
116 #endif
119 * VM-related types
121 typedef ulong_t pfn_t; /* page frame number */
122 typedef ulong_t pgcnt_t; /* number of pages */
123 typedef long spgcnt_t; /* signed number of pages */
125 typedef uchar_t use_t; /* use count for swap. */
126 typedef short sysid_t;
127 typedef short index_t;
128 typedef void *timeout_id_t; /* opaque handle from timeout(9F) */
129 typedef void *bufcall_id_t; /* opaque handle from bufcall(9F) */
132 * The size of off_t and related types depends on the setting of
133 * _FILE_OFFSET_BITS. (Note that other system headers define other types
134 * related to those defined here.)
136 * If _LARGEFILE64_SOURCE is defined, variants of these types that are
137 * explicitly 64 bits wide become available.
139 #ifndef _OFF_T
140 #define _OFF_T
142 #if defined(_LP64) || _FILE_OFFSET_BITS == 32
143 typedef long off_t; /* offsets within files */
144 #elif _FILE_OFFSET_BITS == 64
145 typedef longlong_t off_t; /* offsets within files */
146 #endif
148 #if defined(_LARGEFILE64_SOURCE)
149 #ifdef _LP64
150 typedef off_t off64_t; /* offsets within files */
151 #else
152 typedef longlong_t off64_t; /* offsets within files */
153 #endif
154 #endif /* _LARGEFILE64_SOURCE */
156 #endif /* _OFF_T */
158 #if defined(_LP64) || _FILE_OFFSET_BITS == 32
159 typedef ulong_t ino_t; /* expanded inode type */
160 typedef long blkcnt_t; /* count of file blocks */
161 typedef ulong_t fsblkcnt_t; /* count of file system blocks */
162 typedef ulong_t fsfilcnt_t; /* count of files */
163 #elif _FILE_OFFSET_BITS == 64
164 typedef u_longlong_t ino_t; /* expanded inode type */
165 typedef longlong_t blkcnt_t; /* count of file blocks */
166 typedef u_longlong_t fsblkcnt_t; /* count of file system blocks */
167 typedef u_longlong_t fsfilcnt_t; /* count of files */
168 #endif
170 #if defined(_LARGEFILE64_SOURCE)
171 #ifdef _LP64
172 typedef ino_t ino64_t; /* expanded inode type */
173 typedef blkcnt_t blkcnt64_t; /* count of file blocks */
174 typedef fsblkcnt_t fsblkcnt64_t; /* count of file system blocks */
175 typedef fsfilcnt_t fsfilcnt64_t; /* count of files */
176 #else
177 typedef u_longlong_t ino64_t; /* expanded inode type */
178 typedef longlong_t blkcnt64_t; /* count of file blocks */
179 typedef u_longlong_t fsblkcnt64_t; /* count of file system blocks */
180 typedef u_longlong_t fsfilcnt64_t; /* count of files */
181 #endif
182 #endif /* _LARGEFILE64_SOURCE */
184 #ifdef _LP64
185 typedef int blksize_t; /* used for block sizes */
186 #else
187 typedef long blksize_t; /* used for block sizes */
188 #endif
190 #if defined(__XOPEN_OR_POSIX)
191 typedef enum { _B_FALSE, _B_TRUE } boolean_t;
192 #else
193 typedef enum { B_FALSE, B_TRUE } boolean_t;
194 #ifdef _KERNEL
195 #define VALID_BOOLEAN(x) (((x) == B_FALSE) || ((x) == B_TRUE))
196 #define VOID2BOOLEAN(x) (((uintptr_t)(x) == 0) ? B_FALSE : B_TRUE)
197 #endif /* _KERNEL */
198 #endif /* defined(__XOPEN_OR_POSIX) */
200 #ifdef _KERNEL
201 #define BOOLEAN2VOID(x) ((x) ? 1 : 0)
202 #endif /* _KERNEL */
205 * The {u,}pad64_t types can be used in structures such that those structures
206 * may be accessed by code produced by compilation environments which don't
207 * support a 64 bit integral datatype. The intention is not to allow
208 * use of these fields in such environments, but to maintain the alignment
209 * and offsets of the structure.
211 * Similar comments for {u,}pad128_t.
213 * Note that these types do NOT generate any stronger alignment constraints
214 * than those available in the underlying ABI. See <sys/isa_defs.h>
216 #if defined(_INT64_TYPE)
217 typedef int64_t pad64_t;
218 typedef uint64_t upad64_t;
219 #else
220 typedef union {
221 double _d;
222 int32_t _l[2];
223 } pad64_t;
225 typedef union {
226 double _d;
227 uint32_t _l[2];
228 } upad64_t;
229 #endif
231 typedef union {
232 long double _q;
233 int32_t _l[4];
234 } pad128_t;
236 typedef union {
237 long double _q;
238 uint32_t _l[4];
239 } upad128_t;
241 typedef longlong_t offset_t;
242 typedef u_longlong_t u_offset_t;
243 typedef u_longlong_t len_t;
244 typedef u_longlong_t diskaddr_t;
245 #if (defined(_KERNEL) || defined(_KMEMUSER) || defined(_BOOT))
246 typedef uint64_t paddr_t;
247 #endif
250 * Definitions remaining from previous partial support for 64-bit file
251 * offsets. This partial support for devices greater than 2gb requires
252 * compiler support for long long.
254 #ifdef _LONG_LONG_LTOH
255 typedef union {
256 offset_t _f; /* Full 64 bit offset value */
257 struct {
258 int32_t _l; /* lower 32 bits of offset value */
259 int32_t _u; /* upper 32 bits of offset value */
260 } _p;
261 } lloff_t;
262 #endif
264 #ifdef _LONG_LONG_HTOL
265 typedef union {
266 offset_t _f; /* Full 64 bit offset value */
267 struct {
268 int32_t _u; /* upper 32 bits of offset value */
269 int32_t _l; /* lower 32 bits of offset value */
270 } _p;
271 } lloff_t;
272 #endif
274 #ifdef _LONG_LONG_LTOH
275 typedef union {
276 longlong_t _f; /* Full 64 bit disk address value */
277 struct {
278 int32_t _l; /* lower 32 bits of disk address value */
279 int32_t _u; /* upper 32 bits of disk address value */
280 } _p;
281 } lldaddr_t;
282 #endif
284 #ifdef _LONG_LONG_HTOL
285 typedef union {
286 longlong_t _f; /* Full 64 bit disk address value */
287 struct {
288 int32_t _u; /* upper 32 bits of disk address value */
289 int32_t _l; /* lower 32 bits of disk address value */
290 } _p;
291 } lldaddr_t;
292 #endif
294 typedef uint_t k_fltset_t; /* kernel fault set type */
297 * The following type is for various kinds of identifiers. The
298 * actual type must be the same for all since some system calls
299 * (such as sigsend) take arguments that may be any of these
300 * types. The enumeration type idtype_t defined in sys/procset.h
301 * is used to indicate what type of id is being specified --
302 * a process id, process group id, session id, scheduling class id,
303 * user id, group id, project id, task id or zone id.
305 #if defined(_LP64) || defined(_I32LPx)
306 typedef int id_t;
307 #else
308 typedef long id_t; /* (historical version) */
309 #endif
311 typedef id_t lgrp_id_t; /* lgroup ID */
314 * Type useconds_t is an unsigned integral type capable of storing
315 * values at least in the range of zero to 1,000,000.
317 typedef uint_t useconds_t; /* Time, in microseconds */
319 #ifndef _SUSECONDS_T
320 #define _SUSECONDS_T
321 typedef long suseconds_t; /* signed # of microseconds */
322 #endif /* _SUSECONDS_T */
325 * Typedefs for dev_t components.
327 #if defined(_LP64) || defined(_I32LPx)
328 typedef uint_t major_t; /* major part of device number */
329 typedef uint_t minor_t; /* minor part of device number */
330 #else
331 typedef ulong_t major_t; /* (historical version) */
332 typedef ulong_t minor_t; /* (historical version) */
333 #endif
336 * The data type of a thread priority.
338 typedef short pri_t;
341 * The data type for a CPU flags field. (Can be extended to larger unsigned
342 * types, if needed, limited by ability to update atomically.)
344 typedef ushort_t cpu_flag_t;
347 * For compatibility reasons the following typedefs (prefixed o_)
348 * can't grow regardless of the EFT definition. Although,
349 * applications should not explicitly use these typedefs
350 * they may be included via a system header definition.
351 * WARNING: These typedefs may be removed in a future
352 * release.
353 * ex. the definitions in s5inode.h (now obsoleted)
354 * remained small to preserve compatibility
355 * in the S5 file system type.
357 typedef ushort_t o_mode_t; /* old file attribute type */
358 typedef short o_dev_t; /* old device type */
359 typedef ushort_t o_uid_t; /* old UID type */
360 typedef o_uid_t o_gid_t; /* old GID type */
361 typedef short o_nlink_t; /* old file link type */
362 typedef short o_pid_t; /* old process id type */
363 typedef ushort_t o_ino_t; /* old inode type */
367 * POSIX and XOPEN Declarations
369 typedef int key_t; /* IPC key type */
370 #if defined(_LP64) || defined(_I32LPx)
371 typedef uint_t mode_t; /* file attribute type */
372 #else
373 typedef ulong_t mode_t; /* (historical version) */
374 #endif
376 #ifndef _UID_T
377 #define _UID_T
378 typedef unsigned int uid_t; /* UID type */
379 #endif /* _UID_T */
381 typedef uid_t gid_t; /* GID type */
383 typedef uint32_t datalink_id_t;
384 typedef uint32_t vrid_t;
386 typedef id_t taskid_t;
387 typedef id_t projid_t;
388 typedef id_t poolid_t;
389 typedef id_t zoneid_t;
390 typedef id_t ctid_t;
393 * POSIX definitions are same as defined in thread.h and synch.h.
394 * Any changes made to here should be reflected in corresponding
395 * files as described in comments.
397 typedef uint_t pthread_t; /* = thread_t in thread.h */
398 typedef uint_t pthread_key_t; /* = thread_key_t in thread.h */
400 /* "Magic numbers" tagging synchronization object types */
401 #define _MUTEX_MAGIC 0x4d58 /* "MX" */
402 #define _SEMA_MAGIC 0x534d /* "SM" */
403 #define _COND_MAGIC 0x4356 /* "CV" */
404 #define _RWL_MAGIC 0x5257 /* "RW" */
406 typedef struct _pthread_mutex { /* = mutex_t in synch.h */
407 struct {
408 uint16_t __pthread_mutex_flag1;
409 uint8_t __pthread_mutex_flag2;
410 uint8_t __pthread_mutex_ceiling;
411 uint16_t __pthread_mutex_type;
412 uint16_t __pthread_mutex_magic;
413 } __pthread_mutex_flags;
414 union {
415 struct {
416 uint8_t __pthread_mutex_pad[8];
417 } __pthread_mutex_lock64;
418 struct {
419 uint32_t __pthread_ownerpid;
420 uint32_t __pthread_lockword;
421 } __pthread_mutex_lock32;
422 upad64_t __pthread_mutex_owner64;
423 } __pthread_mutex_lock;
424 upad64_t __pthread_mutex_data;
425 } pthread_mutex_t;
427 typedef struct _pthread_cond { /* = cond_t in synch.h */
428 struct {
429 uint8_t __pthread_cond_flag[4];
430 uint16_t __pthread_cond_type;
431 uint16_t __pthread_cond_magic;
432 } __pthread_cond_flags;
433 upad64_t __pthread_cond_data;
434 } pthread_cond_t;
437 * UNIX 98 Extension
439 typedef struct _pthread_rwlock { /* = rwlock_t in synch.h */
440 int32_t __pthread_rwlock_readers;
441 uint16_t __pthread_rwlock_type;
442 uint16_t __pthread_rwlock_magic;
443 pthread_mutex_t __pthread_rwlock_mutex;
444 pthread_cond_t __pthread_rwlock_readercv;
445 pthread_cond_t __pthread_rwlock_writercv;
446 } pthread_rwlock_t;
449 * SUSV3
451 typedef struct {
452 uint32_t __pthread_barrier_count;
453 uint32_t __pthread_barrier_current;
454 upad64_t __pthread_barrier_cycle;
455 upad64_t __pthread_barrier_reserved;
456 pthread_mutex_t __pthread_barrier_lock;
457 pthread_cond_t __pthread_barrier_cond;
458 } pthread_barrier_t;
460 typedef pthread_mutex_t pthread_spinlock_t;
463 * attributes for threads, dynamically allocated by library
465 typedef struct _pthread_attr {
466 void *__pthread_attrp;
467 } pthread_attr_t;
470 * attributes for mutex, dynamically allocated by library
472 typedef struct _pthread_mutexattr {
473 void *__pthread_mutexattrp;
474 } pthread_mutexattr_t;
477 * attributes for cond, dynamically allocated by library
479 typedef struct _pthread_condattr {
480 void *__pthread_condattrp;
481 } pthread_condattr_t;
484 * pthread_once
486 typedef struct _once {
487 upad64_t __pthread_once_pad[4];
488 } pthread_once_t;
491 * UNIX 98 Extensions
492 * attributes for rwlock, dynamically allocated by library
494 typedef struct _pthread_rwlockattr {
495 void *__pthread_rwlockattrp;
496 } pthread_rwlockattr_t;
499 * SUSV3
500 * attributes for pthread_barrier_t, dynamically allocated by library
502 typedef struct {
503 void *__pthread_barrierattrp;
504 } pthread_barrierattr_t;
506 typedef ulong_t dev_t; /* expanded device type */
508 #if defined(_LP64) || defined(_I32LPx)
509 typedef uint_t nlink_t; /* file link type */
510 typedef int pid_t; /* process id type */
511 #else
512 typedef ulong_t nlink_t; /* (historical version) */
513 typedef long pid_t; /* (historical version) */
514 #endif
516 #if !defined(_SIZE_T) || __cplusplus >= 199711L
517 #define _SIZE_T
518 #if defined(_LP64) || defined(_I32LPx)
519 typedef ulong_t size_t; /* size of something in bytes */
520 #else
521 typedef uint_t size_t; /* (historical version) */
522 #endif
523 #endif /* _SIZE_T */
525 #ifndef _SSIZE_T
526 #define _SSIZE_T
527 #if defined(_LP64) || defined(_I32LPx)
528 typedef long ssize_t; /* size of something in bytes or -1 */
529 #else
530 typedef int ssize_t; /* (historical version) */
531 #endif
532 #endif /* _SSIZE_T */
534 #if !defined(_TIME_T) || __cplusplus >= 199711L
535 #define _TIME_T
536 typedef long time_t; /* time of day in seconds */
537 #endif /* _TIME_T */
539 #if !defined(_CLOCK_T) || __cplusplus >= 199711L
540 #define _CLOCK_T
541 typedef long clock_t; /* relative time in a specified resolution */
542 #endif /* ifndef _CLOCK_T */
544 #ifndef _CLOCKID_T
545 #define _CLOCKID_T
546 typedef int clockid_t; /* clock identifier type */
547 #endif /* ifndef _CLOCKID_T */
549 #ifndef _TIMER_T
550 #define _TIMER_T
551 typedef int timer_t; /* timer identifier type */
552 #endif /* ifndef _TIMER_T */
554 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
556 /* BEGIN CSTYLED */
557 typedef unsigned char unchar;
558 typedef unsigned short ushort;
559 typedef unsigned int uint;
560 typedef unsigned long ulong;
561 /* END CSTYLED */
563 #if defined(_KERNEL) || defined(_FAKE_KERNEL)
565 #define SHRT_MIN (-32768) /* min value of a "short int" */
566 #define SHRT_MAX 32767 /* max value of a "short int" */
567 #define USHRT_MAX 65535 /* max of "unsigned short int" */
568 #define INT_MIN (-2147483647-1) /* min value of an "int" */
569 #define INT_MAX 2147483647 /* max value of an "int" */
570 #define UINT_MAX 4294967295U /* max value of an "unsigned int" */
571 #if defined(_LP64)
572 #define LONG_MIN (-9223372036854775807L-1L)
573 /* min value of a "long int" */
574 #define LONG_MAX 9223372036854775807L
575 /* max value of a "long int" */
576 #define ULONG_MAX 18446744073709551615UL
577 /* max of "unsigned long int" */
578 #else /* _ILP32 */
579 #define LONG_MIN (-2147483647L-1L)
580 /* min value of a "long int" */
581 #define LONG_MAX 2147483647L /* max value of a "long int" */
582 #define ULONG_MAX 4294967295UL /* max of "unsigned long int" */
583 #endif
585 #define LLONG_MIN (-9223372036854775807LL-1LL)
586 /* min of "long long int" */
587 #define LLONG_MAX 9223372036854775807LL
588 /* max of "long long int" */
589 #define ULLONG_MAX 18446744073709551615ULL
590 /* max of "unsigned long long int" */
592 #endif /* defined(_KERNEL) */
594 #define P_MYPID ((pid_t)0)
597 * The following is the value of type id_t to use to indicate the
598 * caller's current id. See procset.h for the type idtype_t
599 * which defines which kind of id is being specified.
601 #define P_MYID (-1)
602 #define NOPID (pid_t)(-1)
604 #ifndef NODEV
605 #define NODEV (dev_t)(-1l)
606 #ifdef _SYSCALL32
607 #define NODEV32 (dev32_t)(-1)
608 #endif /* _SYSCALL32 */
609 #endif /* NODEV */
612 * The following value of type pfn_t is used to indicate
613 * invalid page frame number.
615 #define PFN_INVALID ((pfn_t)-1)
616 #define PFN_SUSPENDED ((pfn_t)-2)
618 /* BEGIN CSTYLED */
619 typedef unsigned char u_char;
620 typedef unsigned short u_short;
621 typedef unsigned int u_int;
622 typedef unsigned long u_long;
623 typedef struct _quad { int val[2]; } quad_t; /* used by UFS */
624 typedef quad_t quad; /* used by UFS */
625 /* END CSTYLED */
628 * Nested include for BSD/sockets source compatibility.
629 * (The select macros used to be defined here).
631 #include <sys/select.h>
633 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
636 * _VOID was defined to be either void or char but this is not
637 * required because previous SunOS compilers have accepted the void
638 * type. However, because many system header and source files use the
639 * void keyword, the volatile keyword, and ANSI C function prototypes,
640 * non-ANSI compilers cannot compile the system anyway. The _VOID macro
641 * should therefore not be used and remains for source compatibility
642 * only.
644 /* CSTYLED */
645 #define _VOID void
647 #ifdef __cplusplus
649 #endif
651 #endif /* _SYS_TYPES_H */