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