libefi: import efichar.c for ucs2 support
[unleashed.git] / include / sys / types.h
blob9891bfd15edd5385caf8d11f568c012d9bef9160
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 typedef int32_t t_scalar_t;
90 typedef uint32_t t_uscalar_t;
93 * POSIX Extensions
95 typedef unsigned char uchar_t;
96 typedef unsigned short ushort_t;
97 typedef unsigned int uint_t;
98 typedef unsigned long ulong_t;
100 typedef char *caddr_t; /* ?<core address> type */
101 typedef long daddr_t; /* <disk address> type */
102 typedef short cnt_t; /* ?<count> type */
104 #if !defined(_PTRDIFF_T) || __cplusplus >= 199711L
105 #define _PTRDIFF_T
106 #if defined(_LP64) || defined(_I32LPx)
107 typedef long ptrdiff_t; /* pointer difference */
108 #else
109 typedef int ptrdiff_t; /* (historical version) */
110 #endif
111 #endif
114 * VM-related types
116 typedef ulong_t pfn_t; /* page frame number */
117 typedef ulong_t pgcnt_t; /* number of pages */
118 typedef long spgcnt_t; /* signed number of pages */
120 typedef uchar_t use_t; /* use count for swap. */
121 typedef short sysid_t;
122 typedef short index_t;
123 typedef void *timeout_id_t; /* opaque handle from timeout(9F) */
124 typedef void *bufcall_id_t; /* opaque handle from bufcall(9F) */
127 * The size of off_t and related types depends on the setting of
128 * _FILE_OFFSET_BITS. (Note that other system headers define other types
129 * related to those defined here.)
131 * If _LARGEFILE64_SOURCE is defined, variants of these types that are
132 * explicitly 64 bits wide become available.
134 #ifndef _OFF_T
135 #define _OFF_T
137 #if defined(_LP64) || _FILE_OFFSET_BITS == 32
138 typedef long off_t; /* offsets within files */
139 #elif _FILE_OFFSET_BITS == 64
140 typedef longlong_t off_t; /* offsets within files */
141 #endif
143 #if defined(_LARGEFILE64_SOURCE)
144 #ifdef _LP64
145 typedef off_t off64_t; /* offsets within files */
146 #else
147 typedef longlong_t off64_t; /* offsets within files */
148 #endif
149 #endif /* _LARGEFILE64_SOURCE */
151 #endif /* _OFF_T */
153 #if defined(_LP64) || _FILE_OFFSET_BITS == 32
154 typedef ulong_t ino_t; /* expanded inode type */
155 typedef long blkcnt_t; /* count of file blocks */
156 typedef ulong_t fsblkcnt_t; /* count of file system blocks */
157 typedef ulong_t fsfilcnt_t; /* count of files */
158 #elif _FILE_OFFSET_BITS == 64
159 typedef u_longlong_t ino_t; /* expanded inode type */
160 typedef longlong_t blkcnt_t; /* count of file blocks */
161 typedef u_longlong_t fsblkcnt_t; /* count of file system blocks */
162 typedef u_longlong_t fsfilcnt_t; /* count of files */
163 #endif
165 #if defined(_LARGEFILE64_SOURCE)
166 #ifdef _LP64
167 typedef ino_t ino64_t; /* expanded inode type */
168 typedef blkcnt_t blkcnt64_t; /* count of file blocks */
169 typedef fsblkcnt_t fsblkcnt64_t; /* count of file system blocks */
170 typedef fsfilcnt_t fsfilcnt64_t; /* count of files */
171 #else
172 typedef u_longlong_t ino64_t; /* expanded inode type */
173 typedef longlong_t blkcnt64_t; /* count of file blocks */
174 typedef u_longlong_t fsblkcnt64_t; /* count of file system blocks */
175 typedef u_longlong_t fsfilcnt64_t; /* count of files */
176 #endif
177 #endif /* _LARGEFILE64_SOURCE */
179 #ifdef _LP64
180 typedef int blksize_t; /* used for block sizes */
181 #else
182 typedef long blksize_t; /* used for block sizes */
183 #endif
185 #if defined(__XOPEN_OR_POSIX)
186 typedef enum { _B_FALSE, _B_TRUE } boolean_t;
187 #else
188 typedef enum { B_FALSE, B_TRUE } boolean_t;
189 #endif /* defined(__XOPEN_OR_POSIX) */
192 * The {u,}pad64_t types can be used in structures such that those structures
193 * may be accessed by code produced by compilation environments which don't
194 * support a 64 bit integral datatype. The intention is not to allow
195 * use of these fields in such environments, but to maintain the alignment
196 * and offsets of the structure.
198 * Similar comments for {u,}pad128_t.
200 * Note that these types do NOT generate any stronger alignment constraints
201 * than those available in the underlying ABI. See <sys/isa_defs.h>
203 #if defined(_INT64_TYPE)
204 typedef int64_t pad64_t;
205 typedef uint64_t upad64_t;
206 #else
207 typedef union {
208 double _d;
209 int32_t _l[2];
210 } pad64_t;
212 typedef union {
213 double _d;
214 uint32_t _l[2];
215 } upad64_t;
216 #endif
218 typedef union {
219 long double _q;
220 int32_t _l[4];
221 } pad128_t;
223 typedef union {
224 long double _q;
225 uint32_t _l[4];
226 } upad128_t;
228 typedef longlong_t offset_t;
229 typedef u_longlong_t uoff_t;
230 typedef u_longlong_t len_t;
231 typedef u_longlong_t diskaddr_t;
232 #if (defined(_KERNEL) || defined(_KMEMUSER) || defined(_BOOT))
233 typedef uint64_t paddr_t;
234 #endif
237 * Definitions remaining from previous partial support for 64-bit file
238 * offsets. This partial support for devices greater than 2gb requires
239 * compiler support for long long.
241 #ifdef _LONG_LONG_LTOH
242 typedef union {
243 offset_t _f; /* Full 64 bit offset value */
244 struct {
245 int32_t _l; /* lower 32 bits of offset value */
246 int32_t _u; /* upper 32 bits of offset value */
247 } _p;
248 } lloff_t;
249 #endif
251 #ifdef _LONG_LONG_HTOL
252 typedef union {
253 offset_t _f; /* Full 64 bit offset value */
254 struct {
255 int32_t _u; /* upper 32 bits of offset value */
256 int32_t _l; /* lower 32 bits of offset value */
257 } _p;
258 } lloff_t;
259 #endif
261 #ifdef _LONG_LONG_LTOH
262 typedef union {
263 longlong_t _f; /* Full 64 bit disk address value */
264 struct {
265 int32_t _l; /* lower 32 bits of disk address value */
266 int32_t _u; /* upper 32 bits of disk address value */
267 } _p;
268 } lldaddr_t;
269 #endif
271 #ifdef _LONG_LONG_HTOL
272 typedef union {
273 longlong_t _f; /* Full 64 bit disk address value */
274 struct {
275 int32_t _u; /* upper 32 bits of disk address value */
276 int32_t _l; /* lower 32 bits of disk address value */
277 } _p;
278 } lldaddr_t;
279 #endif
281 typedef uint_t k_fltset_t; /* kernel fault set type */
284 * The following type is for various kinds of identifiers. The
285 * actual type must be the same for all since some system calls
286 * (such as sigsend) take arguments that may be any of these
287 * types. The enumeration type idtype_t defined in sys/procset.h
288 * is used to indicate what type of id is being specified --
289 * a process id, process group id, session id, scheduling class id,
290 * user id, group id, project id, task id or zone id.
292 typedef int id_t;
294 typedef id_t lgrp_id_t; /* lgroup ID */
297 * Type useconds_t is an unsigned integral type capable of storing
298 * values at least in the range of zero to 1,000,000.
300 typedef uint_t useconds_t; /* Time, in microseconds */
302 #ifndef _SUSECONDS_T
303 #define _SUSECONDS_T
304 typedef long suseconds_t; /* signed # of microseconds */
305 #endif /* _SUSECONDS_T */
308 * Typedefs for dev_t components.
310 typedef unsigned int major_t; /* major part of device number */
311 typedef unsigned int minor_t; /* minor part of device number */
314 * The data type of a thread priority.
316 typedef short pri_t;
319 * The data type for a CPU flags field. (Can be extended to larger unsigned
320 * types, if needed, limited by ability to update atomically.)
322 typedef ushort_t cpu_flag_t;
325 * For compatibility reasons the following typedefs (prefixed o_)
326 * can't grow regardless of the EFT definition. Although,
327 * applications should not explicitly use these typedefs
328 * they may be included via a system header definition.
329 * WARNING: These typedefs may be removed in a future
330 * release.
331 * ex. the definitions in s5inode.h (now obsoleted)
332 * remained small to preserve compatibility
333 * in the S5 file system type.
335 typedef ushort_t o_mode_t; /* old file attribute type */
336 typedef short o_dev_t; /* old device type */
337 typedef ushort_t o_uid_t; /* old UID type */
338 typedef o_uid_t o_gid_t; /* old GID type */
339 typedef short o_nlink_t; /* old file link type */
340 typedef short o_pid_t; /* old process id type */
341 typedef ushort_t o_ino_t; /* old inode type */
345 * POSIX and XOPEN Declarations
347 typedef int key_t; /* IPC key type */
348 typedef unsigned int mode_t; /* file attribute type */
350 #ifndef _UID_T
351 #define _UID_T
352 typedef unsigned int uid_t; /* UID type */
353 #endif /* _UID_T */
355 typedef uid_t gid_t; /* GID type */
357 typedef uint32_t datalink_id_t;
358 typedef uint32_t vrid_t;
360 typedef id_t taskid_t;
361 typedef id_t projid_t;
362 typedef id_t poolid_t;
363 typedef id_t zoneid_t;
364 typedef id_t ctid_t;
367 * POSIX definitions are same as defined in thread.h and synch.h.
368 * Any changes made to here should be reflected in corresponding
369 * files as described in comments.
371 typedef uint_t pthread_t; /* = thread_t in thread.h */
372 typedef uint_t pthread_key_t; /* = thread_key_t in thread.h */
374 /* "Magic numbers" tagging synchronization object types */
375 #define _MUTEX_MAGIC 0x4d58 /* "MX" */
376 #define _SEMA_MAGIC 0x534d /* "SM" */
377 #define _COND_MAGIC 0x4356 /* "CV" */
378 #define _RWL_MAGIC 0x5257 /* "RW" */
380 typedef struct _pthread_mutex { /* = mutex_t in synch.h */
381 struct {
382 uint16_t __pthread_mutex_flag1;
383 uint8_t __pthread_mutex_flag2;
384 uint8_t __pthread_mutex_ceiling;
385 uint16_t __pthread_mutex_type;
386 uint16_t __pthread_mutex_magic;
387 } __pthread_mutex_flags;
388 union {
389 struct {
390 uint8_t __pthread_mutex_pad[8];
391 } __pthread_mutex_lock64;
392 struct {
393 uint32_t __pthread_ownerpid;
394 uint32_t __pthread_lockword;
395 } __pthread_mutex_lock32;
396 upad64_t __pthread_mutex_owner64;
397 } __pthread_mutex_lock;
398 upad64_t __pthread_mutex_data;
399 } pthread_mutex_t;
401 typedef struct _pthread_cond { /* = cond_t in synch.h */
402 struct {
403 uint8_t __pthread_cond_flag[4];
404 uint16_t __pthread_cond_type;
405 uint16_t __pthread_cond_magic;
406 } __pthread_cond_flags;
407 upad64_t __pthread_cond_data;
408 } pthread_cond_t;
411 * UNIX 98 Extension
413 typedef struct _pthread_rwlock { /* = rwlock_t in synch.h */
414 int32_t __pthread_rwlock_readers;
415 uint16_t __pthread_rwlock_type;
416 uint16_t __pthread_rwlock_magic;
417 pthread_mutex_t __pthread_rwlock_mutex;
418 pthread_cond_t __pthread_rwlock_readercv;
419 pthread_cond_t __pthread_rwlock_writercv;
420 } pthread_rwlock_t;
423 * SUSV3
425 typedef struct {
426 uint32_t __pthread_barrier_count;
427 uint32_t __pthread_barrier_current;
428 upad64_t __pthread_barrier_cycle;
429 upad64_t __pthread_barrier_reserved;
430 pthread_mutex_t __pthread_barrier_lock;
431 pthread_cond_t __pthread_barrier_cond;
432 } pthread_barrier_t;
434 typedef pthread_mutex_t pthread_spinlock_t;
437 * attributes for threads, dynamically allocated by library
439 typedef struct _pthread_attr {
440 void *__pthread_attrp;
441 } pthread_attr_t;
444 * attributes for mutex, dynamically allocated by library
446 typedef struct _pthread_mutexattr {
447 void *__pthread_mutexattrp;
448 } pthread_mutexattr_t;
451 * attributes for cond, dynamically allocated by library
453 typedef struct _pthread_condattr {
454 void *__pthread_condattrp;
455 } pthread_condattr_t;
458 * pthread_once
460 typedef struct _once {
461 upad64_t __pthread_once_pad[4];
462 } pthread_once_t;
465 * UNIX 98 Extensions
466 * attributes for rwlock, dynamically allocated by library
468 typedef struct _pthread_rwlockattr {
469 void *__pthread_rwlockattrp;
470 } pthread_rwlockattr_t;
473 * SUSV3
474 * attributes for pthread_barrier_t, dynamically allocated by library
476 typedef struct {
477 void *__pthread_barrierattrp;
478 } pthread_barrierattr_t;
480 typedef ulong_t dev_t; /* expanded device type */
482 typedef unsigned int nlink_t; /* file link type */
483 typedef int pid_t; /* process id type */
485 #if !defined(_SIZE_T) || __cplusplus >= 199711L
486 #define _SIZE_T
487 #if defined(_LP64) || defined(_I32LPx)
488 typedef ulong_t size_t; /* size of something in bytes */
489 #else
490 typedef uint_t size_t; /* (historical version) */
491 #endif
492 #endif /* _SIZE_T */
494 #ifndef _SSIZE_T
495 #define _SSIZE_T
496 #if defined(_LP64) || defined(_I32LPx)
497 typedef long ssize_t; /* size of something in bytes or -1 */
498 #else
499 typedef int ssize_t; /* (historical version) */
500 #endif
501 #endif /* _SSIZE_T */
503 #if !defined(_TIME_T) || __cplusplus >= 199711L
504 #define _TIME_T
505 typedef long time_t; /* time of day in seconds */
506 #endif /* _TIME_T */
508 #if !defined(_CLOCK_T) || __cplusplus >= 199711L
509 #define _CLOCK_T
510 typedef long clock_t; /* relative time in a specified resolution */
511 #endif /* ifndef _CLOCK_T */
513 #ifndef _CLOCKID_T
514 #define _CLOCKID_T
515 typedef int clockid_t; /* clock identifier type */
516 #endif /* ifndef _CLOCKID_T */
518 #ifndef _TIMER_T
519 #define _TIMER_T
520 typedef int timer_t; /* timer identifier type */
521 #endif /* ifndef _TIMER_T */
523 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
525 /* BEGIN CSTYLED */
526 typedef unsigned char unchar;
527 typedef unsigned short ushort;
528 typedef unsigned int uint;
529 typedef unsigned long ulong;
530 /* END CSTYLED */
532 #if defined(_KERNEL)
534 #define SHRT_MIN (-32768) /* min value of a "short int" */
535 #define SHRT_MAX 32767 /* max value of a "short int" */
536 #define USHRT_MAX 65535 /* max of "unsigned short int" */
537 #define INT_MIN (-2147483647-1) /* min value of an "int" */
538 #define INT_MAX 2147483647 /* max value of an "int" */
539 #define UINT_MAX 4294967295U /* max value of an "unsigned int" */
540 #if defined(_LP64)
541 #define LONG_MIN (-9223372036854775807L-1L)
542 /* min value of a "long int" */
543 #define LONG_MAX 9223372036854775807L
544 /* max value of a "long int" */
545 #define ULONG_MAX 18446744073709551615UL
546 /* max of "unsigned long int" */
547 #else /* _ILP32 */
548 #define LONG_MIN (-2147483647L-1L)
549 /* min value of a "long int" */
550 #define LONG_MAX 2147483647L /* max value of a "long int" */
551 #define ULONG_MAX 4294967295UL /* max of "unsigned long int" */
552 #endif
554 #define LLONG_MIN (-9223372036854775807LL-1LL)
555 /* min of "long long int" */
556 #define LLONG_MAX 9223372036854775807LL
557 /* max of "long long int" */
558 #define ULLONG_MAX 18446744073709551615ULL
559 /* max of "unsigned long long int" */
561 #endif /* defined(_KERNEL) */
563 #define P_MYPID ((pid_t)0)
566 * The following is the value of type id_t to use to indicate the
567 * caller's current id. See procset.h for the type idtype_t
568 * which defines which kind of id is being specified.
570 #define P_MYID (-1)
571 #define NOPID (pid_t)(-1)
573 #ifndef NODEV
574 #define NODEV (dev_t)(-1l)
575 #ifdef _SYSCALL32
576 #define NODEV32 (dev32_t)(-1)
577 #endif /* _SYSCALL32 */
578 #endif /* NODEV */
581 * The following value of type pfn_t is used to indicate
582 * invalid page frame number.
584 #define PFN_INVALID ((pfn_t)-1)
585 #define PFN_SUSPENDED ((pfn_t)-2)
587 /* BEGIN CSTYLED */
588 typedef unsigned char u_char;
589 typedef unsigned short u_short;
590 typedef unsigned int u_int;
591 typedef unsigned long u_long;
592 typedef struct _quad { int val[2]; } quad_t; /* used by UFS */
593 typedef quad_t quad; /* used by UFS */
594 /* END CSTYLED */
597 * Nested include for BSD/sockets source compatibility.
598 * (The select macros used to be defined here).
600 #include <sys/select.h>
602 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
605 * _VOID was defined to be either void or char but this is not
606 * required because previous SunOS compilers have accepted the void
607 * type. However, because many system header and source files use the
608 * void keyword, the volatile keyword, and ANSI C function prototypes,
609 * non-ANSI compilers cannot compile the system anyway. The _VOID macro
610 * should therefore not be used and remains for source compatibility
611 * only.
613 /* CSTYLED */
614 #define _VOID void
616 #ifdef __cplusplus
618 #endif
620 #endif /* _SYS_TYPES_H */