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]
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.
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.
52 #include <sys/inttypes.h>
54 #include <sys/int_types.h>
57 #if defined(_KERNEL) || defined(_SYSCALL32)
58 #include <sys/types32.h>
65 typedef long long longlong_t
;
66 typedef unsigned long long u_longlong_t
;
69 * These types (t_{u}scalar_t) exist because the XTI/TPI/DLPI standards had
70 * to use them instead of int32_t and uint32_t because DEC had
71 * shipped 64-bit wide.
73 typedef int32_t t_scalar_t
;
74 typedef uint32_t t_uscalar_t
;
79 typedef unsigned char uchar_t
;
80 typedef unsigned short ushort_t
;
81 typedef unsigned int uint_t
;
82 typedef unsigned long ulong_t
;
84 typedef char *caddr_t
; /* ?<core address> type */
85 typedef long daddr_t
; /* <disk address> type */
86 typedef short cnt_t
; /* ?<count> type */
88 #if !defined(_PTRDIFF_T) || __cplusplus >= 199711L
90 #if defined(_LP64) || defined(_I32LPx)
91 typedef long ptrdiff_t; /* pointer difference */
93 typedef int ptrdiff_t; /* (historical version) */
100 typedef ulong_t pfn_t
; /* page frame number */
101 typedef ulong_t pgcnt_t
; /* number of pages */
102 typedef long spgcnt_t
; /* signed number of pages */
104 typedef uchar_t use_t
; /* use count for swap. */
105 typedef short sysid_t
;
106 typedef short index_t
;
107 typedef void *timeout_id_t
; /* opaque handle from timeout(9F) */
108 typedef void *bufcall_id_t
; /* opaque handle from bufcall(9F) */
112 typedef int64_t off_t
; /* offsets within files */
113 typedef off_t off64_t
; /* compat alias */
116 typedef uint64_t ino_t
; /* expanded inode type */
117 typedef int64_t blkcnt_t
; /* count of file blocks */
118 typedef uint64_t fsblkcnt_t
; /* count of file system blocks */
119 typedef uint64_t fsfilcnt_t
; /* count of files */
122 typedef ino_t ino64_t
;
123 typedef blkcnt_t blkcnt64_t
;
124 typedef fsblkcnt_t fsblkcnt64_t
;
125 typedef fsfilcnt_t fsfilcnt64_t
;
127 typedef int32_t blksize_t
; /* used for block sizes */
129 typedef enum { B_FALSE
, B_TRUE
} boolean_t
;
132 * The {u,}pad64_t types can be used in structures such that those structures
133 * may be accessed by code produced by compilation environments which don't
134 * support a 64 bit integral datatype. The intention is not to allow
135 * use of these fields in such environments, but to maintain the alignment
136 * and offsets of the structure.
138 * Similar comments for {u,}pad128_t.
140 * Note that these types do NOT generate any stronger alignment constraints
141 * than those available in the underlying ABI. See <sys/isa_defs.h>
143 #if defined(_INT64_TYPE)
144 typedef int64_t pad64_t
;
145 typedef uint64_t upad64_t
;
168 typedef off_t offset_t
;
169 typedef uint64_t uoff_t
;
170 typedef uint64_t len_t
;
171 typedef uint64_t diskaddr_t
;
172 #if (defined(_KERNEL) || defined(_KMEMUSER) || defined(_BOOT))
173 typedef uint64_t paddr_t
;
177 * Definitions remaining from previous partial support for 64-bit file
178 * offsets. This partial support for devices greater than 2gb requires
179 * compiler support for long long.
181 #ifdef _LONG_LONG_LTOH
183 offset_t _f
; /* Full 64 bit offset value */
185 int32_t _l
; /* lower 32 bits of offset value */
186 int32_t _u
; /* upper 32 bits of offset value */
191 #ifdef _LONG_LONG_HTOL
193 offset_t _f
; /* Full 64 bit offset value */
195 int32_t _u
; /* upper 32 bits of offset value */
196 int32_t _l
; /* lower 32 bits of offset value */
201 #ifdef _LONG_LONG_LTOH
203 longlong_t _f
; /* Full 64 bit disk address value */
205 int32_t _l
; /* lower 32 bits of disk address value */
206 int32_t _u
; /* upper 32 bits of disk address value */
211 #ifdef _LONG_LONG_HTOL
213 longlong_t _f
; /* Full 64 bit disk address value */
215 int32_t _u
; /* upper 32 bits of disk address value */
216 int32_t _l
; /* lower 32 bits of disk address value */
221 typedef uint_t k_fltset_t
; /* kernel fault set type */
224 * The following type is for various kinds of identifiers. The
225 * actual type must be the same for all since some system calls
226 * (such as sigsend) take arguments that may be any of these
227 * types. The enumeration type idtype_t defined in sys/procset.h
228 * is used to indicate what type of id is being specified --
229 * a process id, process group id, session id, scheduling class id,
230 * user id, group id, project id, task id or zone id.
234 typedef id_t lgrp_id_t
; /* lgroup ID */
237 * Type useconds_t is an unsigned integral type capable of storing
238 * values at least in the range of zero to 1,000,000.
240 typedef uint_t useconds_t
; /* Time, in microseconds */
244 typedef long suseconds_t
; /* signed # of microseconds */
245 #endif /* _SUSECONDS_T */
248 * Typedefs for dev_t components.
250 typedef unsigned int major_t
; /* major part of device number */
251 typedef unsigned int minor_t
; /* minor part of device number */
254 * The data type of a thread priority.
259 * The data type for a CPU flags field. (Can be extended to larger unsigned
260 * types, if needed, limited by ability to update atomically.)
262 typedef ushort_t cpu_flag_t
;
265 * For compatibility reasons the following typedefs (prefixed o_)
266 * can't grow regardless of the EFT definition. Although,
267 * applications should not explicitly use these typedefs
268 * they may be included via a system header definition.
269 * WARNING: These typedefs may be removed in a future
271 * ex. the definitions in s5inode.h (now obsoleted)
272 * remained small to preserve compatibility
273 * in the S5 file system type.
275 typedef ushort_t o_mode_t
; /* old file attribute type */
276 typedef short o_dev_t
; /* old device type */
277 typedef ushort_t o_uid_t
; /* old UID type */
278 typedef o_uid_t o_gid_t
; /* old GID type */
279 typedef short o_nlink_t
; /* old file link type */
280 typedef short o_pid_t
; /* old process id type */
281 typedef ushort_t o_ino_t
; /* old inode type */
285 * POSIX and XOPEN Declarations
287 typedef int key_t
; /* IPC key type */
288 typedef uint32_t mode_t
; /* file attribute type */
292 typedef uint32_t uid_t
; /* UID type */
295 typedef uid_t gid_t
; /* GID type */
297 typedef uint32_t datalink_id_t
;
298 typedef uint32_t vrid_t
;
300 typedef id_t taskid_t
;
301 typedef id_t projid_t
;
302 typedef id_t poolid_t
;
303 typedef id_t zoneid_t
;
307 * POSIX definitions are same as defined in thread.h and synch.h.
308 * Any changes made to here should be reflected in corresponding
309 * files as described in comments.
311 typedef uint_t pthread_t
; /* = thread_t in thread.h */
312 typedef uint_t pthread_key_t
; /* = thread_key_t in thread.h */
314 /* "Magic numbers" tagging synchronization object types */
315 #define _MUTEX_MAGIC 0x4d58 /* "MX" */
316 #define _SEMA_MAGIC 0x534d /* "SM" */
317 #define _COND_MAGIC 0x4356 /* "CV" */
318 #define _RWL_MAGIC 0x5257 /* "RW" */
320 typedef struct _pthread_mutex
{ /* = mutex_t in synch.h */
322 uint16_t __pthread_mutex_flag1
;
323 uint8_t __pthread_mutex_flag2
;
324 uint8_t __pthread_mutex_ceiling
;
325 uint16_t __pthread_mutex_type
;
326 uint16_t __pthread_mutex_magic
;
327 } __pthread_mutex_flags
;
330 uint8_t __pthread_mutex_pad
[8];
331 } __pthread_mutex_lock64
;
333 uint32_t __pthread_ownerpid
;
334 uint32_t __pthread_lockword
;
335 } __pthread_mutex_lock32
;
336 upad64_t __pthread_mutex_owner64
;
337 } __pthread_mutex_lock
;
338 upad64_t __pthread_mutex_data
;
341 typedef struct _pthread_cond
{ /* = cond_t in synch.h */
343 uint8_t __pthread_cond_flag
[4];
344 uint16_t __pthread_cond_type
;
345 uint16_t __pthread_cond_magic
;
346 } __pthread_cond_flags
;
347 upad64_t __pthread_cond_data
;
353 typedef struct _pthread_rwlock
{ /* = rwlock_t in synch.h */
354 int32_t __pthread_rwlock_readers
;
355 uint16_t __pthread_rwlock_type
;
356 uint16_t __pthread_rwlock_magic
;
357 pthread_mutex_t __pthread_rwlock_mutex
;
358 pthread_cond_t __pthread_rwlock_readercv
;
359 pthread_cond_t __pthread_rwlock_writercv
;
366 uint32_t __pthread_barrier_count
;
367 uint32_t __pthread_barrier_current
;
368 upad64_t __pthread_barrier_cycle
;
369 upad64_t __pthread_barrier_reserved
;
370 pthread_mutex_t __pthread_barrier_lock
;
371 pthread_cond_t __pthread_barrier_cond
;
374 typedef pthread_mutex_t pthread_spinlock_t
;
377 * attributes for threads, dynamically allocated by library
379 typedef struct _pthread_attr
{
380 void *__pthread_attrp
;
384 * attributes for mutex, dynamically allocated by library
386 typedef struct _pthread_mutexattr
{
387 void *__pthread_mutexattrp
;
388 } pthread_mutexattr_t
;
391 * attributes for cond, dynamically allocated by library
393 typedef struct _pthread_condattr
{
394 void *__pthread_condattrp
;
395 } pthread_condattr_t
;
400 typedef struct _once
{
401 upad64_t __pthread_once_pad
[4];
406 * attributes for rwlock, dynamically allocated by library
408 typedef struct _pthread_rwlockattr
{
409 void *__pthread_rwlockattrp
;
410 } pthread_rwlockattr_t
;
414 * attributes for pthread_barrier_t, dynamically allocated by library
417 void *__pthread_barrierattrp
;
418 } pthread_barrierattr_t
;
420 typedef ulong_t dev_t
; /* expanded device type */
422 typedef uint32_t nlink_t
; /* file link type */
423 typedef int pid_t
; /* process id type */
425 #if !defined(_SIZE_T) || __cplusplus >= 199711L
427 #if defined(_LP64) || defined(_I32LPx)
428 typedef ulong_t
size_t; /* size of something in bytes */
430 typedef uint_t
size_t; /* (historical version) */
436 #if defined(_LP64) || defined(_I32LPx)
437 typedef long ssize_t
; /* size of something in bytes or -1 */
439 typedef int ssize_t
; /* (historical version) */
441 #endif /* _SSIZE_T */
443 #if !defined(_TIME_T) || __cplusplus >= 199711L
445 typedef long time_t; /* time of day in seconds */
448 #if !defined(_CLOCK_T) || __cplusplus >= 199711L
450 typedef long clock_t; /* relative time in a specified resolution */
451 #endif /* ifndef _CLOCK_T */
455 typedef int clockid_t
; /* clock identifier type */
456 #endif /* ifndef _CLOCKID_T */
460 typedef int timer_t
; /* timer identifier type */
461 #endif /* ifndef _TIMER_T */
463 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
466 typedef unsigned char unchar
;
467 typedef unsigned short ushort
;
468 typedef unsigned int uint
;
469 typedef unsigned long ulong
;
474 #define SHRT_MIN (-32768) /* min value of a "short int" */
475 #define SHRT_MAX 32767 /* max value of a "short int" */
476 #define USHRT_MAX 65535 /* max of "unsigned short int" */
477 #define INT_MIN (-2147483647-1) /* min value of an "int" */
478 #define INT_MAX 2147483647 /* max value of an "int" */
479 #define UINT_MAX 4294967295U /* max value of an "unsigned int" */
481 #define LONG_MIN (-9223372036854775807L-1L)
482 /* min value of a "long int" */
483 #define LONG_MAX 9223372036854775807L
484 /* max value of a "long int" */
485 #define ULONG_MAX 18446744073709551615UL
486 /* max of "unsigned long int" */
488 #define LONG_MIN (-2147483647L-1L)
489 /* min value of a "long int" */
490 #define LONG_MAX 2147483647L /* max value of a "long int" */
491 #define ULONG_MAX 4294967295UL /* max of "unsigned long int" */
494 #define LLONG_MIN (-9223372036854775807LL-1LL)
495 /* min of "long long int" */
496 #define LLONG_MAX 9223372036854775807LL
497 /* max of "long long int" */
498 #define ULLONG_MAX 18446744073709551615ULL
499 /* max of "unsigned long long int" */
501 #define OFF_MIN LLONG_MIN
502 #define OFF_MAX LLONG_MAX
504 #endif /* defined(_KERNEL) */
506 #define P_MYPID ((pid_t)0)
509 * The following is the value of type id_t to use to indicate the
510 * caller's current id. See procset.h for the type idtype_t
511 * which defines which kind of id is being specified.
514 #define NOPID (pid_t)(-1)
517 #define NODEV (dev_t)(-1l)
519 #define NODEV32 (dev32_t)(-1)
520 #endif /* _SYSCALL32 */
524 * The following value of type pfn_t is used to indicate
525 * invalid page frame number.
527 #define PFN_INVALID ((pfn_t)-1)
528 #define PFN_SUSPENDED ((pfn_t)-2)
531 typedef unsigned char u_char
;
532 typedef unsigned short u_short
;
533 typedef unsigned int u_int
;
534 typedef unsigned long u_long
;
535 typedef struct _quad
{ int val
[2]; } quad_t
; /* used by UFS */
536 typedef quad_t quad
; /* used by UFS */
540 * Nested include for BSD/sockets source compatibility.
541 * (The select macros used to be defined here).
543 #include <sys/select.h>
545 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
548 * _VOID was defined to be either void or char but this is not
549 * required because previous SunOS compilers have accepted the void
550 * type. However, because many system header and source files use the
551 * void keyword, the volatile keyword, and ANSI C function prototypes,
552 * non-ANSI compilers cannot compile the system anyway. The _VOID macro
553 * should therefore not be used and remains for source compatibility
563 #endif /* _SYS_TYPES_H */