Home | History | Annotate | Download | only in sys
      1 /*
      2  * CDDL HEADER START
      3  *
      4  * The contents of this file are subject to the terms of the
      5  * Common Development and Distribution License, Version 1.0 only
      6  * (the "License").  You may not use this file except in compliance
      7  * with the License.
      8  *
      9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
     10  * or http://www.opensolaris.org/os/licensing.
     11  * See the License for the specific language governing permissions
     12  * and limitations under the License.
     13  *
     14  * When distributing Covered Code, include this CDDL HEADER in each
     15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
     16  * If applicable, add the following below this CDDL HEADER, with the
     17  * fields enclosed by brackets "[]" replaced with your own identifying
     18  * information: Portions Copyright [yyyy] [name of copyright owner]
     19  *
     20  * CDDL HEADER END
     21  */
     22 /*
     23  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
     24  * Use is subject to license terms.
     25  */
     26 
     27 /*
     28  *	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T
     29  *	  All Rights Reserved
     30  */
     31 
     32 /*
     33  * University Copyright- Copyright (c) 1982, 1986, 1988
     34  * The Regents of the University of California
     35  * All Rights Reserved
     36  *
     37  * University Acknowledgment- Portions of this document are derived from
     38  * software developed by the University of California, Berkeley, and its
     39  * contributors.
     40  */
     41 
     42 #ifndef	_SYS_TYPES_H
     43 #define	_SYS_TYPES_H
     44 
     45 #pragma ident	"%Z%%M%	%I%	%E% SMI"
     46 
     47 /*
     48  * Include fixed width type declarations proposed by the ISO/JTC1/SC22/WG14 C
     49  * committee's working draft for the revision of the current ISO C standard,
     50  * ISO/IEC 9899:1990 Programming language - C.  These are not currently
     51  * required by any standard but constitute a useful, general purpose set
     52  * of type definitions which is namespace clean with respect to all standards.
     53  */
     54 
     55 #include <sys/int_types.h>
     56 #include <sys/feature_tests.h>
     57 
     58 #ifdef __cplusplus
     59 extern "C" {
     60 #endif
     61 
     62 #ifndef _ASM
     63 
     64 /* From SunOS types.h */
     65 #if defined(mc68000)
     66 typedef	struct _physadr { short r[1]; } *physadr;
     67 typedef	struct _label { int val[13]; } label_t;
     68 #elif defined(__i386)
     69 typedef	struct _physadr { short r[1]; } *physadr;
     70 typedef	struct _label { int val[8]; } label_t;
     71 #elif defined(__sparc)
     72 typedef	struct _physadr { int r[1]; } *physadr;
     73 typedef	struct _label { int val[2]; } label_t;
     74 #else
     75 typedef	struct _physadr { int r[1]; } *physadr;
     76 typedef	struct _label { int val[10]; } label_t;
     77 #endif
     78 
     79 /* POSIX Extensions */
     80 
     81 typedef unsigned char   uchar_t;
     82 typedef unsigned short  ushort_t;
     83 typedef unsigned int    uint_t;
     84 typedef unsigned long   ulong_t;
     85 
     86 
     87 /* For BSD compatibility */
     88 typedef char 		*addr_t;	/* ?<core address> type */
     89 
     90 typedef char 		*caddr_t;	/* ?<core address> type */
     91 typedef long		daddr_t;	/* <disk address> type */
     92 typedef short		cnt_t;		/* ?<count> type */
     93 typedef ulong_t		pgcnt_t;	/* number of pages */
     94 
     95 #ifdef _ILP32
     96 typedef ulong_t 	paddr_t;	/* <physical address> type */
     97 typedef	long		swblk_t;
     98 #endif
     99 
    100 typedef uchar_t 	use_t;		/* use count for swap.  */
    101 typedef short		sysid_t;
    102 typedef short		index_t;
    103 typedef short		lock_t;		/* lock work for busy wait */
    104 typedef enum boolean { B_FALSE, B_TRUE } boolean_t;
    105 typedef ulong_t		l_dev_t;
    106 
    107 /*
    108  * The following protects users who use other than Sun compilers
    109  * (eg, GNU C) that don't support long long, and need to include
    110  * this header file.
    111  */
    112 #ifdef _LONGLONG_TYPE
    113 typedef	long long		longlong_t;
    114 typedef	unsigned long long	u_longlong_t;
    115 #else
    116 #ifdef GCC
    117 typedef int64_t longlong_t;
    118 typedef uint64_t u_longlong_t;
    119 #else
    120 /* used to reserve space and generate alignment */
    121 typedef	union {
    122 	int32_t	l[2];
    123 	double	d;
    124 } longlong_t;
    125 typedef	union {
    126 	uint32_t	l[2];
    127 	double		d;
    128 } u_longlong_t;
    129 #endif	/* GCC */
    130 #endif	/* _LONGLONG_TYPE */
    131 
    132 /*
    133  * The {u,}pad64_t types can be used in structures such that those structures
    134  * may be accessed by code produced by compilation environments which don't
    135  * support a 64 bit integral datatype.  The intention is not to allow
    136  * use of these fields in such environments, but to maintain the alignment
    137  * and offsets of the structure.
    138  *
    139  * Similar comments for {u,}pad128_t.
    140  *
    141  * Note that these types do NOT generate any stronger alignment constraints
    142  * than those available in the underlying ABI.  See <sys/isa_list.h>
    143  */
    144 #ifdef _LONGLONG_TYPE
    145 typedef int64_t		pad64_t;
    146 typedef	uint64_t	upad64_t;
    147 #else
    148 typedef union {
    149 	double   _d;
    150 	int32_t  _l[2];
    151 } pad64_t;
    152 
    153 typedef union {
    154 	double   _d;
    155 	uint32_t _l[2];
    156 } upad64_t;
    157 #endif /* _LONGLONG_TYPE */
    158 
    159 typedef union {
    160 	long double	_q;
    161 	int32_t		_l[4];
    162 } pad128_t;
    163 
    164 typedef union {
    165 	long double	_q;
    166 	uint32_t	_l[4];
    167 } upad128_t;
    168 
    169 /*
    170  * attributes for threads, dynamically allocated by library
    171  */
    172 typedef	struct {
    173 	void	*__pthread_attrp;
    174 } pthread_attr_t;
    175 
    176 /* types related to file sizes, counts, offsets, etc. */
    177 #if defined(_LP64) || _FILE_OFFSET_BITS == 32
    178 typedef long		off_t;		/* ?<offset> type */
    179 typedef long		blkcnt_t;	/* counts file blocks */
    180 typedef ulong_t		fsblkcnt_t;	/* counts file system blocks */
    181 typedef ulong_t		fsfilcnt_t;	/* counts files */
    182 typedef ulong_t		ino_t;		/* expanded inode type	*/
    183 #elif _FILE_OFFSET_BITS == 64
    184 typedef longlong_t	off_t;		/* offsets within files */
    185 typedef longlong_t	blkcnt_t;	/* count of file blocks */
    186 typedef u_longlong_t	fsblkcnt_t;	/* count of file system blocks */
    187 typedef u_longlong_t	fsfilcnt_t;	/* count of files */
    188 typedef u_longlong_t	ino_t;		/* expanded inode type */
    189 #endif
    190 
    191 #ifdef _LP64
    192 typedef	int		blksize_t;	/* used for block sizes */
    193 #else
    194 typedef	long		blksize_t;	/* used for block sizes */
    195 #endif
    196 
    197 #ifdef _LARGEFILE64_SOURCE
    198 #ifdef _LP64
    199 typedef off_t		off64_t;
    200 typedef blkcnt_t	blkcnt64_t;
    201 typedef fsblkcnt_t	fsblkcnt64_t;
    202 typedef fsfilcnt_t	fsfilcnt64_t;
    203 typedef ino_t		ino64_t;
    204 #else
    205 typedef longlong_t	off64_t;	/* ?<offset> type */
    206 typedef longlong_t	blkcnt64_t;	/* counts file blocks */
    207 typedef u_longlong_t	fsblkcnt64_t;	/* counts file system blocks */
    208 typedef u_longlong_t	fsfilcnt64_t;	/* counts files */
    209 typedef u_longlong_t	ino64_t;	/* expanded inode type	*/
    210 #endif
    211 #endif
    212 
    213 /*
    214  * The following type is for various kinds of identifiers.  The
    215  * actual type must be the same for all since some system calls
    216  * (such as sigsend) take arguments that may be any of these
    217  * types.  The enumeration type idtype_t defined in sys/procset.h
    218  * is used to indicate what type of id is being specified.
    219  */
    220 
    221 typedef	longlong_t	offset_t;
    222 typedef	u_longlong_t	u_offset_t;
    223 typedef	longlong_t	diskaddr_t;
    224 
    225 /*
    226  * These types (t_{u}scalar_t) exist because the XTI/TPI/DLPI standards had
    227  * to use them instead of int32_t and uint32_t because DEC had
    228  * shipped 64-bit wide.
    229  */
    230 #if defined(_LP64) || defined(_I32LPx)
    231 typedef int32_t		t_scalar_t;
    232 typedef uint32_t	t_uscalar_t;
    233 #else
    234 typedef long		t_scalar_t;	/* historical versions */
    235 typedef unsigned long	t_uscalar_t;
    236 #endif	/* defined(_LP64) || defined(_I32LPx) */
    237 
    238 /*
    239  * Partial support for 64-bit file offset enclosed herein,
    240  * specifically used to access devices greater than 2gb.
    241  * However, support for devices greater than 2gb requires compiler
    242  * support for long long.
    243  */
    244 #ifdef _LONG_LONG_LTOH
    245 typedef union lloff {
    246 	offset_t	_f;	/* Full 64 bit offset value */
    247 	struct {
    248 		int32_t _l;	/* lower 32 bits of offset value */
    249 		int32_t _u;	/* upper 32 bits of offset value */
    250 	} _p;
    251 } lloff_t;
    252 #endif
    253 
    254 #ifdef _LONG_LONG_HTOL
    255 typedef union lloff {
    256 	offset_t	_f;	/* Full 64 bit offset value */
    257 	struct {
    258 		int32_t _u;	/* upper 32 bits of offset value */
    259 		int32_t _l;	/* lower 32 bits of offset value */
    260 	} _p;
    261 } lloff_t;
    262 #endif
    263 
    264 #ifdef _LONG_LONG_LTOH
    265 typedef union lldaddr {
    266 	diskaddr_t	_f;	/* Full 64 bit disk address value */
    267 	struct {
    268 		int32_t _l;	/* lower 32 bits of disk address value */
    269 		int32_t _u;	/* upper 32 bits of disk address value */
    270 	} _p;
    271 } lldaddr_t;
    272 #endif
    273 
    274 #ifdef _LONG_LONG_HTOL
    275 typedef union lldaddr {
    276 	diskaddr_t	_f;	/* Full 64 bit disk address value */
    277 	struct {
    278 		int32_t _u;	/* upper 32 bits of disk address value */
    279 		int32_t _l;	/* lower 32 bits of disk address value */
    280 	} _p;
    281 } lldaddr_t;
    282 #endif
    283 
    284 typedef ulong_t k_fltset_t;	/* kernel fault set type */
    285 
    286 #if defined(_LP64) || defined(_I32LPx)
    287 typedef int		id_t;		/* A process id,	*/
    288 					/* process group id,	*/
    289 					/* session id,		*/
    290 					/* scheduling class id, */
    291 					/* user id or group id. */
    292 #else
    293 typedef long		id_t;
    294 #endif
    295 
    296 typedef void	*timeout_id_t;
    297 typedef void	*bufcall_id_t;
    298 
    299 /* Typedefs for dev_t components */
    300 
    301 #if !defined(_LP64) && defined(__cplusplus)
    302 typedef ulong_t major_t;	/* major part of device number */
    303 typedef ulong_t minor_t;	/* minor part of device number */
    304 #else
    305 typedef uint_t major_t;
    306 typedef uint_t minor_t;
    307 #endif
    308 
    309 typedef short	pri_t;
    310 
    311 /*
    312  * For compatibility reasons the following typedefs (prefixed o_)
    313  * can't grow regardless of the EFT definition. Although,
    314  * applications should not explicitly use these typedefs
    315  * they may be included via a system header definition.
    316  * WARNING: These typedefs may be removed in a future
    317  * release.
    318  *		ex. the definitions in s5inode.h (now obsoleted)
    319  *			remained small to preserve compatibility
    320  *			in the S5 file system type.
    321  */
    322 typedef ushort_t o_mode_t;		/* old file attribute type */
    323 typedef short	o_dev_t;		/* old device type	*/
    324 typedef ushort_t o_uid_t;		/* old UID type		*/
    325 typedef o_uid_t	o_gid_t;		/* old GID type		*/
    326 typedef short	o_nlink_t;		/* old file link type	*/
    327 typedef short	o_pid_t;		/* old process id type	*/
    328 typedef ushort_t o_ino_t;		/* old inode type	*/
    329 
    330 /* POSIX and XOPEN Declarations */
    331 
    332 typedef int	key_t;			/* IPC key type */
    333 #if !defined(_LP64) && defined(__cplusplus)
    334 typedef ulong_t	mode_t;			/* file attribute type  */
    335 #else
    336 typedef uint_t	mode_t;
    337 #endif
    338 
    339 #ifndef	_UID_T
    340 #define	_UID_T
    341 #if !defined(_LP64) && defined(__cplusplus)
    342 typedef long	uid_t;			/* UID type		*/
    343 #else
    344 typedef int	uid_t;
    345 #endif
    346 #endif
    347 
    348 typedef uid_t	gid_t;			/* GID type		*/
    349 typedef id_t	taskid_t;		/* task ID type		*/
    350 typedef id_t	projid_t;		/* project ID type	*/
    351 typedef	id_t	poolid_t;		/* pool ID type		*/
    352 typedef id_t	zoneid_t;		/* zone ID type		*/
    353 typedef id_t	ctid_t;			/* contract ID type	*/
    354 
    355 typedef ulong_t	dev_t;			/* expanded device type	*/
    356 
    357 #if !defined(_LP64) && defined(__cplusplus)
    358 typedef ulong_t	nlink_t;		/* file link type	*/
    359 typedef long	pid_t;			/* process id type	*/
    360 #else
    361 typedef uint_t	nlink_t;
    362 typedef int	pid_t;
    363 #endif
    364 
    365 #ifndef	_SIZE_T
    366 #define	_SIZE_T
    367 #if !defined(_LP64) && defined(__cplusplus)
    368 typedef uint_t	size_t;
    369 #else
    370 typedef ulong_t	size_t;
    371 #endif
    372 #endif
    373 
    374 #ifndef	_SSIZE_T
    375 #define	_SSIZE_T
    376 #if !defined(_LP64) && defined(__cplusplus)
    377 typedef int	ssize_t;
    378 #else
    379 typedef long	ssize_t;	/* used by functions which return a */
    380 				/* count of bytes or an error indication */
    381 #endif
    382 #endif
    383 
    384 #ifndef	_TIME_T
    385 #define	_TIME_T
    386 typedef long	time_t;		/* time of day in seconds */
    387 #endif  /* _TIME_T */
    388 
    389 #ifndef	_CLOCK_T
    390 #define	_CLOCK_T
    391 typedef long		clock_t; /* relative time in a specified resolution */
    392 #endif	/* ifndef _CLOCK_T */
    393 
    394 #if (defined(_KERNEL) || !defined(_POSIX_SOURCE))
    395 
    396 /* BEGIN CSTYLED */
    397 typedef unsigned char   unchar;
    398 typedef unsigned int    uint;
    399 typedef unsigned long   ulong;
    400 /* END CSTYLED */
    401 
    402 #if defined(_KERNEL)
    403 
    404 #define	SHRT_MIN	-32768		/* min value of a "short int" */
    405 #define	SHRT_MAX	32767		/* max value of a "short int" */
    406 #define	USHRT_MAX	65535u		/* max value of "unsigned short int" */
    407 #define	INT_MIN		(-2147483647-1)	/* min value of an "int" */
    408 #define	INT_MAX		2147483647	/* max value of an "int" */
    409 #define	UINT_MAX	4294967295u	/* max value of an "unsigned int" */
    410 #if !defined(_LP64)
    411 #define	LONG_MIN	(-2147483647L-1L)	/* min value of a "long int" */
    412 #define	LONG_MAX	2147483647L	/* max value of a "long int" */
    413 #define	ULONG_MAX	4294967295UL	/* max value of "unsigned long int" */
    414 #else
    415 #define	LONG_MIN	(-9223372036854775807L-1L)
    416 #define	LONG_MAX	9223372036854775807L
    417 #define	ULONG_MAX	18446744073709551615UL
    418 #endif
    419 
    420 #endif	/* defined(_KERNEL) */
    421 
    422 
    423 #define	P_MYPID	((pid_t)0)
    424 
    425 /*
    426  * The following is the value of type id_t to use to indicate the
    427  * caller's current id.  See procset.h for the type idtype_t
    428  * which defines which kind of id is being specified.
    429  */
    430 
    431 #define	P_MYID	(-1)
    432 #define	NOPID (pid_t)(-1)
    433 
    434 #ifndef	NODEV
    435 #define	NODEV (dev_t)(-1)
    436 #endif
    437 
    438 #ifdef _ILP32
    439 /*
    440  * A host identifier is used to uniquely define a particular node
    441  * on an rfs network.  Its type is as follows.
    442  */
    443 
    444 typedef	long	hostid_t;
    445 
    446 /*
    447  * The following value of type hostid_t is used to indicate the
    448  * current host.  The actual hostid for each host is in the
    449  * kernel global variable rfs_hostid.
    450  */
    451 
    452 #define	P_MYHOSTID	(-1)
    453 #endif
    454 
    455 #endif /* END (defined(_KERNEL) || !defined(_POSIX_SOURCE)) */
    456 
    457 /* BEGIN CSTYLED */
    458 typedef unsigned char	u_char;
    459 typedef unsigned short	u_short;
    460 typedef unsigned int	u_int;
    461 typedef unsigned long	u_long;
    462 typedef unsigned short	ushort;		/* sys III compat */
    463 typedef struct _quad { int val[2]; } quad;	/* used by UFS */
    464 /* END CSTYLED */
    465 
    466 /*
    467  * These were added to allow non-ANSI compilers to compile the system.
    468  */
    469 
    470 #ifdef	__STDC__
    471 
    472 /* _VOID, const, volatile left in for source compatibility */
    473 
    474 /* BEGIN CSTYLED */
    475 #ifndef	_VOID
    476 #define	_VOID	void
    477 #endif
    478 
    479 #else
    480 
    481 #ifndef	_VOID
    482 #define	_VOID	char
    483 #endif
    484 
    485 #ifndef	const
    486 #define	const
    487 #endif
    488 
    489 #ifndef	volatile
    490 #define	volatile
    491 #endif
    492 /* END CSTYLED */
    493 
    494 #endif /* __STDC__ */
    495 
    496 #endif /* _ASM */
    497 
    498 /*
    499  * Nested include for BSD/sockets source compatibility.
    500  * (The select macros used to be defined here).
    501  */
    502 #include <sys/select.h>
    503 /*
    504  * Nested include for BSD compatibility.
    505  */
    506 
    507 #define	AHZ 64
    508 
    509 #include <sys/sysmacros.h>
    510 
    511 #ifdef __cplusplus
    512 }
    513 #endif
    514 
    515 #endif	/* _SYS_TYPES_H */
    516