8702 PCI addresses with physaddr > 0xffffffff can't be mapped in
[unleashed.git] / usr / src / uts / common / sys / types.h
blobdcb2c86283239d77c5b4e66357d7a3a78e6fceeb
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.
30 * Copyright 2016 Joyent, Inc.
33 #ifndef _SYS_TYPES_H
34 #define _SYS_TYPES_H
36 #include <sys/feature_tests.h>
37 #include <sys/isa_defs.h>
40 * Machine dependent definitions moved to <sys/machtypes.h>.
42 #include <sys/machtypes.h>
45 * Include fixed width type declarations proposed by the ISO/JTC1/SC22/WG14 C
46 * committee's working draft for the revision of the current ISO C standard,
47 * ISO/IEC 9899:1990 Programming language - C. These are not currently
48 * required by any standard but constitute a useful, general purpose set
49 * of type definitions which is namespace clean with respect to all standards.
51 #ifdef _KERNEL
52 #include <sys/inttypes.h>
53 #else /* _KERNEL */
54 #include <sys/int_types.h>
55 #endif /* _KERNEL */
57 #if defined(_KERNEL) || defined(_SYSCALL32)
58 #include <sys/types32.h>
59 #endif
61 #ifdef __cplusplus
62 extern "C" {
63 #endif
66 * Strictly conforming ANSI C environments prior to the 1999
67 * revision of the C Standard (ISO/IEC 9899:1999) do not have
68 * the long long data type.
70 #if defined(_LONGLONG_TYPE)
71 typedef long long longlong_t;
72 typedef unsigned long long u_longlong_t;
73 #else
74 /* used to reserve space and generate alignment */
75 typedef union {
76 double _d;
77 int32_t _l[2];
78 } longlong_t;
79 typedef union {
80 double _d;
81 uint32_t _l[2];
82 } u_longlong_t;
83 #endif /* defined(_LONGLONG_TYPE) */
86 * These types (t_{u}scalar_t) exist because the XTI/TPI/DLPI standards had
87 * to use them instead of int32_t and uint32_t because DEC had
88 * shipped 64-bit wide.
90 #if defined(_LP64) || defined(_I32LPx)
91 typedef int32_t t_scalar_t;
92 typedef uint32_t t_uscalar_t;
93 #else
94 typedef long t_scalar_t; /* historical versions */
95 typedef unsigned long t_uscalar_t;
96 #endif /* defined(_LP64) || defined(_I32LPx) */
99 * POSIX Extensions
101 typedef unsigned char uchar_t;
102 typedef unsigned short ushort_t;
103 typedef unsigned int uint_t;
104 typedef unsigned long ulong_t;
106 typedef char *caddr_t; /* ?<core address> type */
107 typedef long daddr_t; /* <disk address> type */
108 typedef short cnt_t; /* ?<count> type */
110 #if !defined(_PTRDIFF_T) || __cplusplus >= 199711L
111 #define _PTRDIFF_T
112 #if defined(_LP64) || defined(_I32LPx)
113 typedef long ptrdiff_t; /* pointer difference */
114 #else
115 typedef int ptrdiff_t; /* (historical version) */
116 #endif
117 #endif
120 * VM-related types
122 typedef ulong_t pfn_t; /* page frame number */
123 typedef ulong_t pgcnt_t; /* number of pages */
124 typedef long spgcnt_t; /* signed number of pages */
126 typedef uchar_t use_t; /* use count for swap. */
127 typedef short sysid_t;
128 typedef short index_t;
129 typedef void *timeout_id_t; /* opaque handle from timeout(9F) */
130 typedef void *bufcall_id_t; /* opaque handle from bufcall(9F) */
133 * The size of off_t and related types depends on the setting of
134 * _FILE_OFFSET_BITS. (Note that other system headers define other types
135 * related to those defined here.)
137 * If _LARGEFILE64_SOURCE is defined, variants of these types that are
138 * explicitly 64 bits wide become available.
140 #ifndef _OFF_T
141 #define _OFF_T
143 #if defined(_LP64) || _FILE_OFFSET_BITS == 32
144 typedef long off_t; /* offsets within files */
145 #elif _FILE_OFFSET_BITS == 64
146 typedef longlong_t off_t; /* offsets within files */
147 #endif
149 #if defined(_LARGEFILE64_SOURCE)
150 #ifdef _LP64
151 typedef off_t off64_t; /* offsets within files */
152 #else
153 typedef longlong_t off64_t; /* offsets within files */
154 #endif
155 #endif /* _LARGEFILE64_SOURCE */
157 #endif /* _OFF_T */
159 #if defined(_LP64) || _FILE_OFFSET_BITS == 32
160 typedef ulong_t ino_t; /* expanded inode type */
161 typedef long blkcnt_t; /* count of file blocks */
162 typedef ulong_t fsblkcnt_t; /* count of file system blocks */
163 typedef ulong_t fsfilcnt_t; /* count of files */
164 #elif _FILE_OFFSET_BITS == 64
165 typedef u_longlong_t ino_t; /* expanded inode type */
166 typedef longlong_t blkcnt_t; /* count of file blocks */
167 typedef u_longlong_t fsblkcnt_t; /* count of file system blocks */
168 typedef u_longlong_t fsfilcnt_t; /* count of files */
169 #endif
171 #if defined(_LARGEFILE64_SOURCE)
172 #ifdef _LP64
173 typedef ino_t ino64_t; /* expanded inode type */
174 typedef blkcnt_t blkcnt64_t; /* count of file blocks */
175 typedef fsblkcnt_t fsblkcnt64_t; /* count of file system blocks */
176 typedef fsfilcnt_t fsfilcnt64_t; /* count of files */
177 #else
178 typedef u_longlong_t ino64_t; /* expanded inode type */
179 typedef longlong_t blkcnt64_t; /* count of file blocks */
180 typedef u_longlong_t fsblkcnt64_t; /* count of file system blocks */
181 typedef u_longlong_t fsfilcnt64_t; /* count of files */
182 #endif
183 #endif /* _LARGEFILE64_SOURCE */
185 #ifdef _LP64
186 typedef int blksize_t; /* used for block sizes */
187 #else
188 typedef long blksize_t; /* used for block sizes */
189 #endif
191 #if defined(__XOPEN_OR_POSIX)
192 typedef enum { _B_FALSE, _B_TRUE } boolean_t;
193 #else
194 typedef enum { B_FALSE, B_TRUE } boolean_t;
195 #ifdef _KERNEL
196 #define VALID_BOOLEAN(x) (((x) == B_FALSE) || ((x) == B_TRUE))
197 #define VOID2BOOLEAN(x) (((uintptr_t)(x) == 0) ? B_FALSE : B_TRUE)
198 #endif /* _KERNEL */
199 #endif /* defined(__XOPEN_OR_POSIX) */
201 #ifdef _KERNEL
202 #define BOOLEAN2VOID(x) ((x) ? 1 : 0)
203 #endif /* _KERNEL */
206 * The {u,}pad64_t types can be used in structures such that those structures
207 * may be accessed by code produced by compilation environments which don't
208 * support a 64 bit integral datatype. The intention is not to allow
209 * use of these fields in such environments, but to maintain the alignment
210 * and offsets of the structure.
212 * Similar comments for {u,}pad128_t.
214 * Note that these types do NOT generate any stronger alignment constraints
215 * than those available in the underlying ABI. See <sys/isa_defs.h>
217 #if defined(_INT64_TYPE)
218 typedef int64_t pad64_t;
219 typedef uint64_t upad64_t;
220 #else
221 typedef union {
222 double _d;
223 int32_t _l[2];
224 } pad64_t;
226 typedef union {
227 double _d;
228 uint32_t _l[2];
229 } upad64_t;
230 #endif
232 typedef union {
233 long double _q;
234 int32_t _l[4];
235 } pad128_t;
237 typedef union {
238 long double _q;
239 uint32_t _l[4];
240 } upad128_t;
242 typedef longlong_t offset_t;
243 typedef u_longlong_t u_offset_t;
244 typedef u_longlong_t len_t;
245 typedef u_longlong_t diskaddr_t;
246 #if (defined(_KERNEL) || defined(_KMEMUSER) || defined(_BOOT))
247 typedef uint64_t paddr_t;
248 #endif
251 * Definitions remaining from previous partial support for 64-bit file
252 * offsets. This partial support for devices greater than 2gb requires
253 * compiler support for long long.
255 #ifdef _LONG_LONG_LTOH
256 typedef union {
257 offset_t _f; /* Full 64 bit offset value */
258 struct {
259 int32_t _l; /* lower 32 bits of offset value */
260 int32_t _u; /* upper 32 bits of offset value */
261 } _p;
262 } lloff_t;
263 #endif
265 #ifdef _LONG_LONG_HTOL
266 typedef union {
267 offset_t _f; /* Full 64 bit offset value */
268 struct {
269 int32_t _u; /* upper 32 bits of offset value */
270 int32_t _l; /* lower 32 bits of offset value */
271 } _p;
272 } lloff_t;
273 #endif
275 #ifdef _LONG_LONG_LTOH
276 typedef union {
277 longlong_t _f; /* Full 64 bit disk address value */
278 struct {
279 int32_t _l; /* lower 32 bits of disk address value */
280 int32_t _u; /* upper 32 bits of disk address value */
281 } _p;
282 } lldaddr_t;
283 #endif
285 #ifdef _LONG_LONG_HTOL
286 typedef union {
287 longlong_t _f; /* Full 64 bit disk address value */
288 struct {
289 int32_t _u; /* upper 32 bits of disk address value */
290 int32_t _l; /* lower 32 bits of disk address value */
291 } _p;
292 } lldaddr_t;
293 #endif
295 typedef uint_t k_fltset_t; /* kernel fault set type */
298 * The following type is for various kinds of identifiers. The
299 * actual type must be the same for all since some system calls
300 * (such as sigsend) take arguments that may be any of these
301 * types. The enumeration type idtype_t defined in sys/procset.h
302 * is used to indicate what type of id is being specified --
303 * a process id, process group id, session id, scheduling class id,
304 * user id, group id, project id, task id or zone id.
306 #if defined(_LP64) || defined(_I32LPx)
307 typedef int id_t;
308 #else
309 typedef long id_t; /* (historical version) */
310 #endif
312 typedef id_t lgrp_id_t; /* lgroup ID */
315 * Type useconds_t is an unsigned integral type capable of storing
316 * values at least in the range of zero to 1,000,000.
318 typedef uint_t useconds_t; /* Time, in microseconds */
320 #ifndef _SUSECONDS_T
321 #define _SUSECONDS_T
322 typedef long suseconds_t; /* signed # of microseconds */
323 #endif /* _SUSECONDS_T */
326 * Typedefs for dev_t components.
328 #if defined(_LP64) || defined(_I32LPx)
329 typedef uint_t major_t; /* major part of device number */
330 typedef uint_t minor_t; /* minor part of device number */
331 #else
332 typedef ulong_t major_t; /* (historical version) */
333 typedef ulong_t minor_t; /* (historical version) */
334 #endif
337 * The data type of a thread priority.
339 typedef short pri_t;
342 * The data type for a CPU flags field. (Can be extended to larger unsigned
343 * types, if needed, limited by ability to update atomically.)
345 typedef ushort_t cpu_flag_t;
348 * For compatibility reasons the following typedefs (prefixed o_)
349 * can't grow regardless of the EFT definition. Although,
350 * applications should not explicitly use these typedefs
351 * they may be included via a system header definition.
352 * WARNING: These typedefs may be removed in a future
353 * release.
354 * ex. the definitions in s5inode.h (now obsoleted)
355 * remained small to preserve compatibility
356 * in the S5 file system type.
358 typedef ushort_t o_mode_t; /* old file attribute type */
359 typedef short o_dev_t; /* old device type */
360 typedef ushort_t o_uid_t; /* old UID type */
361 typedef o_uid_t o_gid_t; /* old GID type */
362 typedef short o_nlink_t; /* old file link type */
363 typedef short o_pid_t; /* old process id type */
364 typedef ushort_t o_ino_t; /* old inode type */
368 * POSIX and XOPEN Declarations
370 typedef int key_t; /* IPC key type */
371 #if defined(_LP64) || defined(_I32LPx)
372 typedef uint_t mode_t; /* file attribute type */
373 #else
374 typedef ulong_t mode_t; /* (historical version) */
375 #endif
377 #ifndef _UID_T
378 #define _UID_T
379 typedef unsigned int uid_t; /* UID type */
380 #endif /* _UID_T */
382 typedef uid_t gid_t; /* GID type */
384 typedef uint32_t datalink_id_t;
385 typedef uint32_t vrid_t;
387 typedef id_t taskid_t;
388 typedef id_t projid_t;
389 typedef id_t poolid_t;
390 typedef id_t zoneid_t;
391 typedef id_t ctid_t;
394 * POSIX definitions are same as defined in thread.h and synch.h.
395 * Any changes made to here should be reflected in corresponding
396 * files as described in comments.
398 typedef uint_t pthread_t; /* = thread_t in thread.h */
399 typedef uint_t pthread_key_t; /* = thread_key_t in thread.h */
401 /* "Magic numbers" tagging synchronization object types */
402 #define _MUTEX_MAGIC 0x4d58 /* "MX" */
403 #define _SEMA_MAGIC 0x534d /* "SM" */
404 #define _COND_MAGIC 0x4356 /* "CV" */
405 #define _RWL_MAGIC 0x5257 /* "RW" */
407 typedef struct _pthread_mutex { /* = mutex_t in synch.h */
408 struct {
409 uint16_t __pthread_mutex_flag1;
410 uint8_t __pthread_mutex_flag2;
411 uint8_t __pthread_mutex_ceiling;
412 uint16_t __pthread_mutex_type;
413 uint16_t __pthread_mutex_magic;
414 } __pthread_mutex_flags;
415 union {
416 struct {
417 uint8_t __pthread_mutex_pad[8];
418 } __pthread_mutex_lock64;
419 struct {
420 uint32_t __pthread_ownerpid;
421 uint32_t __pthread_lockword;
422 } __pthread_mutex_lock32;
423 upad64_t __pthread_mutex_owner64;
424 } __pthread_mutex_lock;
425 upad64_t __pthread_mutex_data;
426 } pthread_mutex_t;
428 typedef struct _pthread_cond { /* = cond_t in synch.h */
429 struct {
430 uint8_t __pthread_cond_flag[4];
431 uint16_t __pthread_cond_type;
432 uint16_t __pthread_cond_magic;
433 } __pthread_cond_flags;
434 upad64_t __pthread_cond_data;
435 } pthread_cond_t;
438 * UNIX 98 Extension
440 typedef struct _pthread_rwlock { /* = rwlock_t in synch.h */
441 int32_t __pthread_rwlock_readers;
442 uint16_t __pthread_rwlock_type;
443 uint16_t __pthread_rwlock_magic;
444 pthread_mutex_t __pthread_rwlock_mutex;
445 pthread_cond_t __pthread_rwlock_readercv;
446 pthread_cond_t __pthread_rwlock_writercv;
447 } pthread_rwlock_t;
450 * SUSV3
452 typedef struct {
453 uint32_t __pthread_barrier_count;
454 uint32_t __pthread_barrier_current;
455 upad64_t __pthread_barrier_cycle;
456 upad64_t __pthread_barrier_reserved;
457 pthread_mutex_t __pthread_barrier_lock;
458 pthread_cond_t __pthread_barrier_cond;
459 } pthread_barrier_t;
461 typedef pthread_mutex_t pthread_spinlock_t;
464 * attributes for threads, dynamically allocated by library
466 typedef struct _pthread_attr {
467 void *__pthread_attrp;
468 } pthread_attr_t;
471 * attributes for mutex, dynamically allocated by library
473 typedef struct _pthread_mutexattr {
474 void *__pthread_mutexattrp;
475 } pthread_mutexattr_t;
478 * attributes for cond, dynamically allocated by library
480 typedef struct _pthread_condattr {
481 void *__pthread_condattrp;
482 } pthread_condattr_t;
485 * pthread_once
487 typedef struct _once {
488 upad64_t __pthread_once_pad[4];
489 } pthread_once_t;
492 * UNIX 98 Extensions
493 * attributes for rwlock, dynamically allocated by library
495 typedef struct _pthread_rwlockattr {
496 void *__pthread_rwlockattrp;
497 } pthread_rwlockattr_t;
500 * SUSV3
501 * attributes for pthread_barrier_t, dynamically allocated by library
503 typedef struct {
504 void *__pthread_barrierattrp;
505 } pthread_barrierattr_t;
507 typedef ulong_t dev_t; /* expanded device type */
509 #if defined(_LP64) || defined(_I32LPx)
510 typedef uint_t nlink_t; /* file link type */
511 typedef int pid_t; /* process id type */
512 #else
513 typedef ulong_t nlink_t; /* (historical version) */
514 typedef long pid_t; /* (historical version) */
515 #endif
517 #if !defined(_SIZE_T) || __cplusplus >= 199711L
518 #define _SIZE_T
519 #if defined(_LP64) || defined(_I32LPx)
520 typedef ulong_t size_t; /* size of something in bytes */
521 #else
522 typedef uint_t size_t; /* (historical version) */
523 #endif
524 #endif /* _SIZE_T */
526 #ifndef _SSIZE_T
527 #define _SSIZE_T
528 #if defined(_LP64) || defined(_I32LPx)
529 typedef long ssize_t; /* size of something in bytes or -1 */
530 #else
531 typedef int ssize_t; /* (historical version) */
532 #endif
533 #endif /* _SSIZE_T */
535 #if !defined(_TIME_T) || __cplusplus >= 199711L
536 #define _TIME_T
537 typedef long time_t; /* time of day in seconds */
538 #endif /* _TIME_T */
540 #if !defined(_CLOCK_T) || __cplusplus >= 199711L
541 #define _CLOCK_T
542 typedef long clock_t; /* relative time in a specified resolution */
543 #endif /* ifndef _CLOCK_T */
545 #ifndef _CLOCKID_T
546 #define _CLOCKID_T
547 typedef int clockid_t; /* clock identifier type */
548 #endif /* ifndef _CLOCKID_T */
550 #ifndef _TIMER_T
551 #define _TIMER_T
552 typedef int timer_t; /* timer identifier type */
553 #endif /* ifndef _TIMER_T */
555 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
557 /* BEGIN CSTYLED */
558 typedef unsigned char unchar;
559 typedef unsigned short ushort;
560 typedef unsigned int uint;
561 typedef unsigned long ulong;
562 /* END CSTYLED */
564 #if defined(_KERNEL) || defined(_FAKE_KERNEL)
566 #define SHRT_MIN (-32768) /* min value of a "short int" */
567 #define SHRT_MAX 32767 /* max value of a "short int" */
568 #define USHRT_MAX 65535 /* max of "unsigned short int" */
569 #define INT_MIN (-2147483647-1) /* min value of an "int" */
570 #define INT_MAX 2147483647 /* max value of an "int" */
571 #define UINT_MAX 4294967295U /* max value of an "unsigned int" */
572 #if defined(_LP64)
573 #define LONG_MIN (-9223372036854775807L-1L)
574 /* min value of a "long int" */
575 #define LONG_MAX 9223372036854775807L
576 /* max value of a "long int" */
577 #define ULONG_MAX 18446744073709551615UL
578 /* max of "unsigned long int" */
579 #else /* _ILP32 */
580 #define LONG_MIN (-2147483647L-1L)
581 /* min value of a "long int" */
582 #define LONG_MAX 2147483647L /* max value of a "long int" */
583 #define ULONG_MAX 4294967295UL /* max of "unsigned long int" */
584 #endif
586 #define LLONG_MIN (-9223372036854775807LL-1LL)
587 /* min of "long long int" */
588 #define LLONG_MAX 9223372036854775807LL
589 /* max of "long long int" */
590 #define ULLONG_MAX 18446744073709551615ULL
591 /* max of "unsigned long long int" */
593 #if defined(_LP64) || _FILE_OFFSET_BITS == 32
594 #define OFF_MIN LONG_MIN
595 #define OFF_MAX LONG_MAX
596 #elif _FILE_OFFSET_BITS == 64
597 #define OFF_MIN LLONG_MIN
598 #define OFF_MAX LLONG_MAX
599 #endif /* _LP64 || _FILE_OFFSET_BITS == 32 */
601 #endif /* defined(_KERNEL) */
603 #define P_MYPID ((pid_t)0)
606 * The following is the value of type id_t to use to indicate the
607 * caller's current id. See procset.h for the type idtype_t
608 * which defines which kind of id is being specified.
610 #define P_MYID (-1)
611 #define NOPID (pid_t)(-1)
613 #ifndef NODEV
614 #define NODEV (dev_t)(-1l)
615 #ifdef _SYSCALL32
616 #define NODEV32 (dev32_t)(-1)
617 #endif /* _SYSCALL32 */
618 #endif /* NODEV */
621 * The following value of type pfn_t is used to indicate
622 * invalid page frame number.
624 #define PFN_INVALID ((pfn_t)-1)
625 #define PFN_SUSPENDED ((pfn_t)-2)
627 /* BEGIN CSTYLED */
628 typedef unsigned char u_char;
629 typedef unsigned short u_short;
630 typedef unsigned int u_int;
631 typedef unsigned long u_long;
632 typedef struct _quad { int val[2]; } quad_t; /* used by UFS */
633 typedef quad_t quad; /* used by UFS */
634 /* END CSTYLED */
637 * Nested include for BSD/sockets source compatibility.
638 * (The select macros used to be defined here).
640 #include <sys/select.h>
642 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
645 * _VOID was defined to be either void or char but this is not
646 * required because previous SunOS compilers have accepted the void
647 * type. However, because many system header and source files use the
648 * void keyword, the volatile keyword, and ANSI C function prototypes,
649 * non-ANSI compilers cannot compile the system anyway. The _VOID macro
650 * should therefore not be used and remains for source compatibility
651 * only.
653 /* CSTYLED */
654 #define _VOID void
656 #ifdef __cplusplus
658 #endif
660 #endif /* _SYS_TYPES_H */