include: demolish _LONGLONG_TYPE; consider "long long" always valid
[unleashed.git] / include / sys / types.h
blob4bc25fe747bfbfdeb6253fe773b966e9db4f3451
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
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;
77 * POSIX Extensions
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
89 #define _PTRDIFF_T
90 #if defined(_LP64) || defined(_I32LPx)
91 typedef long ptrdiff_t; /* pointer difference */
92 #else
93 typedef int ptrdiff_t; /* (historical version) */
94 #endif
95 #endif
98 * VM-related types
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) */
110 #ifndef _OFF_T
111 #define _OFF_T
113 #if defined(_LP64)
114 typedef long off_t; /* offsets within files */
115 #else
116 typedef longlong_t off_t; /* offsets within files */
117 #endif
118 typedef off_t off64_t;
120 #endif /* _OFF_T */
122 #if defined(_LP64)
123 typedef ulong_t ino_t; /* expanded inode type */
124 typedef long blkcnt_t; /* count of file blocks */
125 typedef ulong_t fsblkcnt_t; /* count of file system blocks */
126 typedef ulong_t fsfilcnt_t; /* count of files */
127 #else
128 typedef u_longlong_t ino_t; /* expanded inode type */
129 typedef longlong_t blkcnt_t; /* count of file blocks */
130 typedef u_longlong_t fsblkcnt_t; /* count of file system blocks */
131 typedef u_longlong_t fsfilcnt_t; /* count of files */
132 #endif
134 typedef ino_t ino64_t; /* expanded inode type */
135 typedef blkcnt_t blkcnt64_t; /* count of file blocks */
136 typedef fsblkcnt_t fsblkcnt64_t; /* count of file system blocks */
137 typedef fsfilcnt_t fsfilcnt64_t; /* count of files */
139 #ifdef _LP64
140 typedef int blksize_t; /* used for block sizes */
141 #else
142 typedef long blksize_t; /* used for block sizes */
143 #endif
145 #if defined(__XOPEN_OR_POSIX)
146 typedef enum { _B_FALSE, _B_TRUE } boolean_t;
147 #else
148 typedef enum { B_FALSE, B_TRUE } boolean_t;
149 #endif /* defined(__XOPEN_OR_POSIX) */
152 * The {u,}pad64_t types can be used in structures such that those structures
153 * may be accessed by code produced by compilation environments which don't
154 * support a 64 bit integral datatype. The intention is not to allow
155 * use of these fields in such environments, but to maintain the alignment
156 * and offsets of the structure.
158 * Similar comments for {u,}pad128_t.
160 * Note that these types do NOT generate any stronger alignment constraints
161 * than those available in the underlying ABI. See <sys/isa_defs.h>
163 #if defined(_INT64_TYPE)
164 typedef int64_t pad64_t;
165 typedef uint64_t upad64_t;
166 #else
167 typedef union {
168 double _d;
169 int32_t _l[2];
170 } pad64_t;
172 typedef union {
173 double _d;
174 uint32_t _l[2];
175 } upad64_t;
176 #endif
178 typedef union {
179 long double _q;
180 int32_t _l[4];
181 } pad128_t;
183 typedef union {
184 long double _q;
185 uint32_t _l[4];
186 } upad128_t;
188 typedef longlong_t offset_t;
189 typedef u_longlong_t uoff_t;
190 typedef u_longlong_t len_t;
191 typedef u_longlong_t diskaddr_t;
192 #if (defined(_KERNEL) || defined(_KMEMUSER) || defined(_BOOT))
193 typedef uint64_t paddr_t;
194 #endif
197 * Definitions remaining from previous partial support for 64-bit file
198 * offsets. This partial support for devices greater than 2gb requires
199 * compiler support for long long.
201 #ifdef _LONG_LONG_LTOH
202 typedef union {
203 offset_t _f; /* Full 64 bit offset value */
204 struct {
205 int32_t _l; /* lower 32 bits of offset value */
206 int32_t _u; /* upper 32 bits of offset value */
207 } _p;
208 } lloff_t;
209 #endif
211 #ifdef _LONG_LONG_HTOL
212 typedef union {
213 offset_t _f; /* Full 64 bit offset value */
214 struct {
215 int32_t _u; /* upper 32 bits of offset value */
216 int32_t _l; /* lower 32 bits of offset value */
217 } _p;
218 } lloff_t;
219 #endif
221 #ifdef _LONG_LONG_LTOH
222 typedef union {
223 longlong_t _f; /* Full 64 bit disk address value */
224 struct {
225 int32_t _l; /* lower 32 bits of disk address value */
226 int32_t _u; /* upper 32 bits of disk address value */
227 } _p;
228 } lldaddr_t;
229 #endif
231 #ifdef _LONG_LONG_HTOL
232 typedef union {
233 longlong_t _f; /* Full 64 bit disk address value */
234 struct {
235 int32_t _u; /* upper 32 bits of disk address value */
236 int32_t _l; /* lower 32 bits of disk address value */
237 } _p;
238 } lldaddr_t;
239 #endif
241 typedef uint_t k_fltset_t; /* kernel fault set type */
244 * The following type is for various kinds of identifiers. The
245 * actual type must be the same for all since some system calls
246 * (such as sigsend) take arguments that may be any of these
247 * types. The enumeration type idtype_t defined in sys/procset.h
248 * is used to indicate what type of id is being specified --
249 * a process id, process group id, session id, scheduling class id,
250 * user id, group id, project id, task id or zone id.
252 typedef int id_t;
254 typedef id_t lgrp_id_t; /* lgroup ID */
257 * Type useconds_t is an unsigned integral type capable of storing
258 * values at least in the range of zero to 1,000,000.
260 typedef uint_t useconds_t; /* Time, in microseconds */
262 #ifndef _SUSECONDS_T
263 #define _SUSECONDS_T
264 typedef long suseconds_t; /* signed # of microseconds */
265 #endif /* _SUSECONDS_T */
268 * Typedefs for dev_t components.
270 typedef unsigned int major_t; /* major part of device number */
271 typedef unsigned int minor_t; /* minor part of device number */
274 * The data type of a thread priority.
276 typedef short pri_t;
279 * The data type for a CPU flags field. (Can be extended to larger unsigned
280 * types, if needed, limited by ability to update atomically.)
282 typedef ushort_t cpu_flag_t;
285 * For compatibility reasons the following typedefs (prefixed o_)
286 * can't grow regardless of the EFT definition. Although,
287 * applications should not explicitly use these typedefs
288 * they may be included via a system header definition.
289 * WARNING: These typedefs may be removed in a future
290 * release.
291 * ex. the definitions in s5inode.h (now obsoleted)
292 * remained small to preserve compatibility
293 * in the S5 file system type.
295 typedef ushort_t o_mode_t; /* old file attribute type */
296 typedef short o_dev_t; /* old device type */
297 typedef ushort_t o_uid_t; /* old UID type */
298 typedef o_uid_t o_gid_t; /* old GID type */
299 typedef short o_nlink_t; /* old file link type */
300 typedef short o_pid_t; /* old process id type */
301 typedef ushort_t o_ino_t; /* old inode type */
305 * POSIX and XOPEN Declarations
307 typedef int key_t; /* IPC key type */
308 typedef unsigned int mode_t; /* file attribute type */
310 #ifndef _UID_T
311 #define _UID_T
312 typedef unsigned int uid_t; /* UID type */
313 #endif /* _UID_T */
315 typedef uid_t gid_t; /* GID type */
317 typedef uint32_t datalink_id_t;
318 typedef uint32_t vrid_t;
320 typedef id_t taskid_t;
321 typedef id_t projid_t;
322 typedef id_t poolid_t;
323 typedef id_t zoneid_t;
324 typedef id_t ctid_t;
327 * POSIX definitions are same as defined in thread.h and synch.h.
328 * Any changes made to here should be reflected in corresponding
329 * files as described in comments.
331 typedef uint_t pthread_t; /* = thread_t in thread.h */
332 typedef uint_t pthread_key_t; /* = thread_key_t in thread.h */
334 /* "Magic numbers" tagging synchronization object types */
335 #define _MUTEX_MAGIC 0x4d58 /* "MX" */
336 #define _SEMA_MAGIC 0x534d /* "SM" */
337 #define _COND_MAGIC 0x4356 /* "CV" */
338 #define _RWL_MAGIC 0x5257 /* "RW" */
340 typedef struct _pthread_mutex { /* = mutex_t in synch.h */
341 struct {
342 uint16_t __pthread_mutex_flag1;
343 uint8_t __pthread_mutex_flag2;
344 uint8_t __pthread_mutex_ceiling;
345 uint16_t __pthread_mutex_type;
346 uint16_t __pthread_mutex_magic;
347 } __pthread_mutex_flags;
348 union {
349 struct {
350 uint8_t __pthread_mutex_pad[8];
351 } __pthread_mutex_lock64;
352 struct {
353 uint32_t __pthread_ownerpid;
354 uint32_t __pthread_lockword;
355 } __pthread_mutex_lock32;
356 upad64_t __pthread_mutex_owner64;
357 } __pthread_mutex_lock;
358 upad64_t __pthread_mutex_data;
359 } pthread_mutex_t;
361 typedef struct _pthread_cond { /* = cond_t in synch.h */
362 struct {
363 uint8_t __pthread_cond_flag[4];
364 uint16_t __pthread_cond_type;
365 uint16_t __pthread_cond_magic;
366 } __pthread_cond_flags;
367 upad64_t __pthread_cond_data;
368 } pthread_cond_t;
371 * UNIX 98 Extension
373 typedef struct _pthread_rwlock { /* = rwlock_t in synch.h */
374 int32_t __pthread_rwlock_readers;
375 uint16_t __pthread_rwlock_type;
376 uint16_t __pthread_rwlock_magic;
377 pthread_mutex_t __pthread_rwlock_mutex;
378 pthread_cond_t __pthread_rwlock_readercv;
379 pthread_cond_t __pthread_rwlock_writercv;
380 } pthread_rwlock_t;
383 * SUSV3
385 typedef struct {
386 uint32_t __pthread_barrier_count;
387 uint32_t __pthread_barrier_current;
388 upad64_t __pthread_barrier_cycle;
389 upad64_t __pthread_barrier_reserved;
390 pthread_mutex_t __pthread_barrier_lock;
391 pthread_cond_t __pthread_barrier_cond;
392 } pthread_barrier_t;
394 typedef pthread_mutex_t pthread_spinlock_t;
397 * attributes for threads, dynamically allocated by library
399 typedef struct _pthread_attr {
400 void *__pthread_attrp;
401 } pthread_attr_t;
404 * attributes for mutex, dynamically allocated by library
406 typedef struct _pthread_mutexattr {
407 void *__pthread_mutexattrp;
408 } pthread_mutexattr_t;
411 * attributes for cond, dynamically allocated by library
413 typedef struct _pthread_condattr {
414 void *__pthread_condattrp;
415 } pthread_condattr_t;
418 * pthread_once
420 typedef struct _once {
421 upad64_t __pthread_once_pad[4];
422 } pthread_once_t;
425 * UNIX 98 Extensions
426 * attributes for rwlock, dynamically allocated by library
428 typedef struct _pthread_rwlockattr {
429 void *__pthread_rwlockattrp;
430 } pthread_rwlockattr_t;
433 * SUSV3
434 * attributes for pthread_barrier_t, dynamically allocated by library
436 typedef struct {
437 void *__pthread_barrierattrp;
438 } pthread_barrierattr_t;
440 typedef ulong_t dev_t; /* expanded device type */
442 typedef unsigned int nlink_t; /* file link type */
443 typedef int pid_t; /* process id type */
445 #if !defined(_SIZE_T) || __cplusplus >= 199711L
446 #define _SIZE_T
447 #if defined(_LP64) || defined(_I32LPx)
448 typedef ulong_t size_t; /* size of something in bytes */
449 #else
450 typedef uint_t size_t; /* (historical version) */
451 #endif
452 #endif /* _SIZE_T */
454 #ifndef _SSIZE_T
455 #define _SSIZE_T
456 #if defined(_LP64) || defined(_I32LPx)
457 typedef long ssize_t; /* size of something in bytes or -1 */
458 #else
459 typedef int ssize_t; /* (historical version) */
460 #endif
461 #endif /* _SSIZE_T */
463 #if !defined(_TIME_T) || __cplusplus >= 199711L
464 #define _TIME_T
465 typedef long time_t; /* time of day in seconds */
466 #endif /* _TIME_T */
468 #if !defined(_CLOCK_T) || __cplusplus >= 199711L
469 #define _CLOCK_T
470 typedef long clock_t; /* relative time in a specified resolution */
471 #endif /* ifndef _CLOCK_T */
473 #ifndef _CLOCKID_T
474 #define _CLOCKID_T
475 typedef int clockid_t; /* clock identifier type */
476 #endif /* ifndef _CLOCKID_T */
478 #ifndef _TIMER_T
479 #define _TIMER_T
480 typedef int timer_t; /* timer identifier type */
481 #endif /* ifndef _TIMER_T */
483 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
485 /* BEGIN CSTYLED */
486 typedef unsigned char unchar;
487 typedef unsigned short ushort;
488 typedef unsigned int uint;
489 typedef unsigned long ulong;
490 /* END CSTYLED */
492 #if defined(_KERNEL)
494 #define SHRT_MIN (-32768) /* min value of a "short int" */
495 #define SHRT_MAX 32767 /* max value of a "short int" */
496 #define USHRT_MAX 65535 /* max of "unsigned short int" */
497 #define INT_MIN (-2147483647-1) /* min value of an "int" */
498 #define INT_MAX 2147483647 /* max value of an "int" */
499 #define UINT_MAX 4294967295U /* max value of an "unsigned int" */
500 #if defined(_LP64)
501 #define LONG_MIN (-9223372036854775807L-1L)
502 /* min value of a "long int" */
503 #define LONG_MAX 9223372036854775807L
504 /* max value of a "long int" */
505 #define ULONG_MAX 18446744073709551615UL
506 /* max of "unsigned long int" */
507 #else /* _ILP32 */
508 #define LONG_MIN (-2147483647L-1L)
509 /* min value of a "long int" */
510 #define LONG_MAX 2147483647L /* max value of a "long int" */
511 #define ULONG_MAX 4294967295UL /* max of "unsigned long int" */
512 #endif
514 #define LLONG_MIN (-9223372036854775807LL-1LL)
515 /* min of "long long int" */
516 #define LLONG_MAX 9223372036854775807LL
517 /* max of "long long int" */
518 #define ULLONG_MAX 18446744073709551615ULL
519 /* max of "unsigned long long int" */
521 #if defined(_LP64) || _FILE_OFFSET_BITS == 32
522 #define OFF_MIN LONG_MIN
523 #define OFF_MAX LONG_MAX
524 #elif _FILE_OFFSET_BITS == 64
525 #define OFF_MIN LLONG_MIN
526 #define OFF_MAX LLONG_MAX
527 #endif /* _LP64 || _FILE_OFFSET_BITS == 32 */
529 #endif /* defined(_KERNEL) */
531 #define P_MYPID ((pid_t)0)
534 * The following is the value of type id_t to use to indicate the
535 * caller's current id. See procset.h for the type idtype_t
536 * which defines which kind of id is being specified.
538 #define P_MYID (-1)
539 #define NOPID (pid_t)(-1)
541 #ifndef NODEV
542 #define NODEV (dev_t)(-1l)
543 #ifdef _SYSCALL32
544 #define NODEV32 (dev32_t)(-1)
545 #endif /* _SYSCALL32 */
546 #endif /* NODEV */
549 * The following value of type pfn_t is used to indicate
550 * invalid page frame number.
552 #define PFN_INVALID ((pfn_t)-1)
553 #define PFN_SUSPENDED ((pfn_t)-2)
555 /* BEGIN CSTYLED */
556 typedef unsigned char u_char;
557 typedef unsigned short u_short;
558 typedef unsigned int u_int;
559 typedef unsigned long u_long;
560 typedef struct _quad { int val[2]; } quad_t; /* used by UFS */
561 typedef quad_t quad; /* used by UFS */
562 /* END CSTYLED */
565 * Nested include for BSD/sockets source compatibility.
566 * (The select macros used to be defined here).
568 #include <sys/select.h>
570 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
573 * _VOID was defined to be either void or char but this is not
574 * required because previous SunOS compilers have accepted the void
575 * type. However, because many system header and source files use the
576 * void keyword, the volatile keyword, and ANSI C function prototypes,
577 * non-ANSI compilers cannot compile the system anyway. The _VOID macro
578 * should therefore not be used and remains for source compatibility
579 * only.
581 /* CSTYLED */
582 #define _VOID void
584 #ifdef __cplusplus
586 #endif
588 #endif /* _SYS_TYPES_H */