17c478bdstevel@tonic-gate/*
27c478bdstevel@tonic-gate * CDDL HEADER START
37c478bdstevel@tonic-gate *
47c478bdstevel@tonic-gate * The contents of this file are subject to the terms of the
5ae115bcmrj * Common Development and Distribution License (the "License").
6ae115bcmrj * You may not use this file except in compliance with the License.
77c478bdstevel@tonic-gate *
87c478bdstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bdstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
107c478bdstevel@tonic-gate * See the License for the specific language governing permissions
117c478bdstevel@tonic-gate * and limitations under the License.
127c478bdstevel@tonic-gate *
137c478bdstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
147c478bdstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bdstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
167c478bdstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
177c478bdstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bdstevel@tonic-gate *
197c478bdstevel@tonic-gate * CDDL HEADER END
207c478bdstevel@tonic-gate */
217c478bdstevel@tonic-gate/*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
22b4203d7Marcel Telka/*	  All Rights Reserved	*/
237c478bdstevel@tonic-gate
247c478bdstevel@tonic-gate
257c478bdstevel@tonic-gate/*
267f0b830Edward Pilatowicz * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
277c478bdstevel@tonic-gate * Use is subject to license terms.
28b819ceaGordon Ross *
29b819ceaGordon Ross * Copyright 2013 Nexenta Systems, Inc.  All rights reserved.
301f0c5e6Robert Mustacchi * Copyright 2016 Joyent, Inc.
317c478bdstevel@tonic-gate */
327c478bdstevel@tonic-gate
337c478bdstevel@tonic-gate#ifndef _SYS_TYPES_H
347c478bdstevel@tonic-gate#define	_SYS_TYPES_H
357c478bdstevel@tonic-gate
367c478bdstevel@tonic-gate#include <sys/feature_tests.h>
377c478bdstevel@tonic-gate#include <sys/isa_defs.h>
387c478bdstevel@tonic-gate
397c478bdstevel@tonic-gate/*
407c478bdstevel@tonic-gate * Machine dependent definitions moved to <sys/machtypes.h>.
417c478bdstevel@tonic-gate */
427c478bdstevel@tonic-gate#include <sys/machtypes.h>
437c478bdstevel@tonic-gate
447c478bdstevel@tonic-gate/*
457c478bdstevel@tonic-gate * Include fixed width type declarations proposed by the ISO/JTC1/SC22/WG14 C
467c478bdstevel@tonic-gate * committee's working draft for the revision of the current ISO C standard,
477c478bdstevel@tonic-gate * ISO/IEC 9899:1990 Programming language - C.  These are not currently
487c478bdstevel@tonic-gate * required by any standard but constitute a useful, general purpose set
497c478bdstevel@tonic-gate * of type definitions which is namespace clean with respect to all standards.
507c478bdstevel@tonic-gate */
517c478bdstevel@tonic-gate#ifdef	_KERNEL
527c478bdstevel@tonic-gate#include <sys/inttypes.h>
537c478bdstevel@tonic-gate#else	/* _KERNEL */
547c478bdstevel@tonic-gate#include <sys/int_types.h>
557c478bdstevel@tonic-gate#endif	/* _KERNEL */
567c478bdstevel@tonic-gate
577c478bdstevel@tonic-gate#if defined(_KERNEL) || defined(_SYSCALL32)
587c478bdstevel@tonic-gate#include <sys/types32.h>
597c478bdstevel@tonic-gate#endif
607c478bdstevel@tonic-gate
617c478bdstevel@tonic-gate#ifdef	__cplusplus
627c478bdstevel@tonic-gateextern "C" {
637c478bdstevel@tonic-gate#endif
647c478bdstevel@tonic-gate
657c478bdstevel@tonic-gate/*
667c478bdstevel@tonic-gate * Strictly conforming ANSI C environments prior to the 1999
677c478bdstevel@tonic-gate * revision of the C Standard (ISO/IEC 9899:1999) do not have
687c478bdstevel@tonic-gate * the long long data type.
697c478bdstevel@tonic-gate */
707c478bdstevel@tonic-gate#if defined(_LONGLONG_TYPE)
717c478bdstevel@tonic-gatetypedef	long long		longlong_t;
727c478bdstevel@tonic-gatetypedef	unsigned long long	u_longlong_t;
737c478bdstevel@tonic-gate#else
747c478bdstevel@tonic-gate/* used to reserve space and generate alignment */
757c478bdstevel@tonic-gatetypedef union {
767c478bdstevel@tonic-gate	double	_d;
777c478bdstevel@tonic-gate	int32_t	_l[2];
787c478bdstevel@tonic-gate} longlong_t;
797c478bdstevel@tonic-gatetypedef union {
807c478bdstevel@tonic-gate	double		_d;
817c478bdstevel@tonic-gate	uint32_t	_l[2];
827c478bdstevel@tonic-gate} u_longlong_t;
837c478bdstevel@tonic-gate#endif	/* defined(_LONGLONG_TYPE) */
847c478bdstevel@tonic-gate
857c478bdstevel@tonic-gate/*
867c478bdstevel@tonic-gate * These types (t_{u}scalar_t) exist because the XTI/TPI/DLPI standards had
877c478bdstevel@tonic-gate * to use them instead of int32_t and uint32_t because DEC had
887c478bdstevel@tonic-gate * shipped 64-bit wide.
897c478bdstevel@tonic-gate */
907c478bdstevel@tonic-gate#if defined(_LP64) || defined(_I32LPx)
917c478bdstevel@tonic-gatetypedef int32_t		t_scalar_t;
927c478bdstevel@tonic-gatetypedef uint32_t	t_uscalar_t;
937c478bdstevel@tonic-gate#else
947c478bdstevel@tonic-gatetypedef long		t_scalar_t;	/* historical versions */
957c478bdstevel@tonic-gatetypedef unsigned long	t_uscalar_t;
967c478bdstevel@tonic-gate#endif	/* defined(_LP64) || defined(_I32LPx) */
977c478bdstevel@tonic-gate
987c478bdstevel@tonic-gate/*
997c478bdstevel@tonic-gate * POSIX Extensions
1007c478bdstevel@tonic-gate */
1017c478bdstevel@tonic-gatetypedef	unsigned char	uchar_t;
1027c478bdstevel@tonic-gatetypedef	unsigned short	ushort_t;
1037c478bdstevel@tonic-gatetypedef	unsigned int	uint_t;
1047c478bdstevel@tonic-gatetypedef	unsigned long	ulong_t;
1057c478bdstevel@tonic-gate
1067c478bdstevel@tonic-gatetypedef	char		*caddr_t;	/* ?<core address> type */
1077c478bdstevel@tonic-gatetypedef	long		daddr_t;	/* <disk address> type */
1087c478bdstevel@tonic-gatetypedef	short		cnt_t;		/* ?<count> type */
1097c478bdstevel@tonic-gate
1107c478bdstevel@tonic-gate#if !defined(_PTRDIFF_T) || __cplusplus >= 199711L
1117c478bdstevel@tonic-gate#define	_PTRDIFF_T
1127c478bdstevel@tonic-gate#if defined(_LP64) || defined(_I32LPx)
1137c478bdstevel@tonic-gatetypedef	long	ptrdiff_t;		/* pointer difference */
1147c478bdstevel@tonic-gate#else
1157c478bdstevel@tonic-gatetypedef	int	ptrdiff_t;		/* (historical version) */
1167c478bdstevel@tonic-gate#endif
1177c478bdstevel@tonic-gate#endif
1187c478bdstevel@tonic-gate
1197c478bdstevel@tonic-gate/*
1207c478bdstevel@tonic-gate * VM-related types
1217c478bdstevel@tonic-gate */
1227c478bdstevel@tonic-gatetypedef	ulong_t		pfn_t;		/* page frame number */
1237c478bdstevel@tonic-gatetypedef	ulong_t		pgcnt_t;	/* number of pages */
1247c478bdstevel@tonic-gatetypedef	long		spgcnt_t;	/* signed number of pages */
1257c478bdstevel@tonic-gate
1267c478bdstevel@tonic-gatetypedef	uchar_t		use_t;		/* use count for swap.  */
1277c478bdstevel@tonic-gatetypedef	short		sysid_t;
1287c478bdstevel@tonic-gatetypedef	short		index_t;
1297c478bdstevel@tonic-gatetypedef void		*timeout_id_t;	/* opaque handle from timeout(9F) */
1307c478bdstevel@tonic-gatetypedef void		*bufcall_id_t;	/* opaque handle from bufcall(9F) */
1317c478bdstevel@tonic-gate
1327c478bdstevel@tonic-gate/*
1337c478bdstevel@tonic-gate * The size of off_t and related types depends on the setting of
1347c478bdstevel@tonic-gate * _FILE_OFFSET_BITS.  (Note that other system headers define other types
1357c478bdstevel@tonic-gate * related to those defined here.)
1367c478bdstevel@tonic-gate *
1377c478bdstevel@tonic-gate * If _LARGEFILE64_SOURCE is defined, variants of these types that are
1387c478bdstevel@tonic-gate * explicitly 64 bits wide become available.
1397c478bdstevel@tonic-gate */
1407c478bdstevel@tonic-gate#ifndef _OFF_T
1417c478bdstevel@tonic-gate#define	_OFF_T
1427c478bdstevel@tonic-gate
1437c478bdstevel@tonic-gate#if defined(_LP64) || _FILE_OFFSET_BITS == 32
1447c478bdstevel@tonic-gatetypedef long		off_t;		/* offsets within files */
1457c478bdstevel@tonic-gate#elif _FILE_OFFSET_BITS == 64
1467c478bdstevel@tonic-gatetypedef longlong_t	off_t;		/* offsets within files */
1477c478bdstevel@tonic-gate#endif
1487c478bdstevel@tonic-gate
1497c478bdstevel@tonic-gate#if defined(_LARGEFILE64_SOURCE)
1507c478bdstevel@tonic-gate#ifdef _LP64
1517c478bdstevel@tonic-gatetypedef	off_t		off64_t;	/* offsets within files */
1527c478bdstevel@tonic-gate#else
1537c478bdstevel@tonic-gatetypedef longlong_t	off64_t;	/* offsets within files */
1547c478bdstevel@tonic-gate#endif
1557c478bdstevel@tonic-gate#endif	/* _LARGEFILE64_SOURCE */
1567c478bdstevel@tonic-gate
1577c478bdstevel@tonic-gate#endif /* _OFF_T */
1587c478bdstevel@tonic-gate
1597c478bdstevel@tonic-gate#if defined(_LP64) || _FILE_OFFSET_BITS == 32
1607c478bdstevel@tonic-gatetypedef ulong_t		ino_t;		/* expanded inode type	*/
1617c478bdstevel@tonic-gatetypedef long		blkcnt_t;	/* count of file blocks */
1627c478bdstevel@tonic-gatetypedef ulong_t		fsblkcnt_t;	/* count of file system blocks */
1637c478bdstevel@tonic-gatetypedef ulong_t		fsfilcnt_t;	/* count of files */
1647c478bdstevel@tonic-gate#elif _FILE_OFFSET_BITS == 64
1657c478bdstevel@tonic-gatetypedef u_longlong_t	ino_t;		/* expanded inode type	*/
1667c478bdstevel@tonic-gatetypedef longlong_t	blkcnt_t;	/* count of file blocks */
1677c478bdstevel@tonic-gatetypedef u_longlong_t	fsblkcnt_t;	/* count of file system blocks */
1687c478bdstevel@tonic-gatetypedef u_longlong_t	fsfilcnt_t;	/* count of files */
1697c478bdstevel@tonic-gate#endif
1707c478bdstevel@tonic-gate
1717c478bdstevel@tonic-gate#if defined(_LARGEFILE64_SOURCE)
1727c478bdstevel@tonic-gate#ifdef _LP64
1737c478bdstevel@tonic-gatetypedef	ino_t		ino64_t;	/* expanded inode type */
1747c478bdstevel@tonic-gatetypedef	blkcnt_t	blkcnt64_t;	/* count of file blocks */
1757c478bdstevel@tonic-gatetypedef	fsblkcnt_t	fsblkcnt64_t;	/* count of file system blocks */
1767c478bdstevel@tonic-gatetypedef	fsfilcnt_t	fsfilcnt64_t;	/* count of files */
1777c478bdstevel@tonic-gate#else
1787c478bdstevel@tonic-gatetypedef u_longlong_t	ino64_t;	/* expanded inode type	*/
1797c478bdstevel@tonic-gatetypedef longlong_t	blkcnt64_t;	/* count of file blocks */
1807c478bdstevel@tonic-gatetypedef u_longlong_t	fsblkcnt64_t;	/* count of file system blocks */
1817c478bdstevel@tonic-gatetypedef u_longlong_t	fsfilcnt64_t;	/* count of files */
1827c478bdstevel@tonic-gate#endif
1837c478bdstevel@tonic-gate#endif	/* _LARGEFILE64_SOURCE */
1847c478bdstevel@tonic-gate
1857c478bdstevel@tonic-gate#ifdef _LP64
1867c478bdstevel@tonic-gatetypedef	int		blksize_t;	/* used for block sizes */
1877c478bdstevel@tonic-gate#else
1887c478bdstevel@tonic-gatetypedef	long		blksize_t;	/* used for block sizes */
1897c478bdstevel@tonic-gate#endif
1907c478bdstevel@tonic-gate
1917c478bdstevel@tonic-gate#if defined(__XOPEN_OR_POSIX)
1927c478bdstevel@tonic-gatetypedef enum { _B_FALSE, _B_TRUE } boolean_t;
1937c478bdstevel@tonic-gate#else
1947c478bdstevel@tonic-gatetypedef enum { B_FALSE, B_TRUE } boolean_t;
1957f0b830Edward Pilatowicz#ifdef _KERNEL
1967f0b830Edward Pilatowicz#define	VALID_BOOLEAN(x)	(((x) == B_FALSE) || ((x) == B_TRUE))
1977f0b830Edward Pilatowicz#define	VOID2BOOLEAN(x)		(((uintptr_t)(x) == 0) ? B_FALSE : B_TRUE)
1987f0b830Edward Pilatowicz#endif /* _KERNEL */
1997c478bdstevel@tonic-gate#endif /* defined(__XOPEN_OR_POSIX) */
2007c478bdstevel@tonic-gate
2017f0b830Edward Pilatowicz#ifdef _KERNEL
2027f0b830Edward Pilatowicz#define	BOOLEAN2VOID(x)		((x) ? 1 : 0)
2037f0b830Edward Pilatowicz#endif /* _KERNEL */
2047f0b830Edward Pilatowicz
2057c478bdstevel@tonic-gate/*
2067c478bdstevel@tonic-gate * The {u,}pad64_t types can be used in structures such that those structures
2077c478bdstevel@tonic-gate * may be accessed by code produced by compilation environments which don't
2087c478bdstevel@tonic-gate * support a 64 bit integral datatype.  The intention is not to allow
2097c478bdstevel@tonic-gate * use of these fields in such environments, but to maintain the alignment
2107c478bdstevel@tonic-gate * and offsets of the structure.
2117c478bdstevel@tonic-gate *
2127c478bdstevel@tonic-gate * Similar comments for {u,}pad128_t.
2137c478bdstevel@tonic-gate *
2147c478bdstevel@tonic-gate * Note that these types do NOT generate any stronger alignment constraints
2157c478bdstevel@tonic-gate * than those available in the underlying ABI.  See <sys/isa_defs.h>
2167c478bdstevel@tonic-gate */
2177c478bdstevel@tonic-gate#if defined(_INT64_TYPE)
2187c478bdstevel@tonic-gatetypedef int64_t		pad64_t;
2197c478bdstevel@tonic-gatetypedef	uint64_t	upad64_t;
2207c478bdstevel@tonic-gate#else
2217c478bdstevel@tonic-gatetypedef union {
2227c478bdstevel@tonic-gate	double   _d;
2237c478bdstevel@tonic-gate	int32_t  _l[2];
2247c478bdstevel@tonic-gate} pad64_t;
2257c478bdstevel@tonic-gate
2267c478bdstevel@tonic-gatetypedef union {
2277c478bdstevel@tonic-gate	double   _d;
2287c478bdstevel@tonic-gate	uint32_t _l[2];
2297c478bdstevel@tonic-gate} upad64_t;
2307c478bdstevel@tonic-gate#endif
2317c478bdstevel@tonic-gate
2327c478bdstevel@tonic-gatetypedef union {
2337c478bdstevel@tonic-gate	long double	_q;
2347c478bdstevel@tonic-gate	int32_t		_l[4];
2357c478bdstevel@tonic-gate} pad128_t;
2367c478bdstevel@tonic-gate
2377c478bdstevel@tonic-gatetypedef union {
2387c478bdstevel@tonic-gate	long double	_q;
2397c478bdstevel@tonic-gate	uint32_t	_l[4];
2407c478bdstevel@tonic-gate} upad128_t;
2417c478bdstevel@tonic-gate
2427c478bdstevel@tonic-gatetypedef	longlong_t	offset_t;
2437c478bdstevel@tonic-gatetypedef	u_longlong_t	u_offset_t;
2447c478bdstevel@tonic-gatetypedef u_longlong_t	len_t;
2457c478bdstevel@tonic-gatetypedef	u_longlong_t	diskaddr_t;
246ae115bcmrj#if (defined(_KERNEL) || defined(_KMEMUSER) || defined(_BOOT))
2477c478bdstevel@tonic-gatetypedef	uint64_t	paddr_t;
2487c478bdstevel@tonic-gate#endif
2497c478bdstevel@tonic-gate
2507c478bdstevel@tonic-gate/*
2517c478bdstevel@tonic-gate * Definitions remaining from previous partial support for 64-bit file
2527c478bdstevel@tonic-gate * offsets.  This partial support for devices greater than 2gb requires
2537c478bdstevel@tonic-gate * compiler support for long long.
2547c478bdstevel@tonic-gate */
2557c478bdstevel@tonic-gate#ifdef _LONG_LONG_LTOH
2567c478bdstevel@tonic-gatetypedef union {
2577c478bdstevel@tonic-gate	offset_t	_f;	/* Full 64 bit offset value */
2587c478bdstevel@tonic-gate	struct {
2597c478bdstevel@tonic-gate		int32_t	_l;	/* lower 32 bits of offset value */
2607c478bdstevel@tonic-gate		int32_t	_u;	/* upper 32 bits of offset value */
2617c478bdstevel@tonic-gate	} _p;
2627c478bdstevel@tonic-gate} lloff_t;
2637c478bdstevel@tonic-gate#endif
2647c478bdstevel@tonic-gate
2657c478bdstevel@tonic-gate#ifdef _LONG_LONG_HTOL
2667c478bdstevel@tonic-gatetypedef union {
2677c478bdstevel@tonic-gate	offset_t	_f;	/* Full 64 bit offset value */
2687c478bdstevel@tonic-gate	struct {
2697c478bdstevel@tonic-gate		int32_t	_u;	/* upper 32 bits of offset value */
2707c478bdstevel@tonic-gate		int32_t	_l;	/* lower 32 bits of offset value */
2717c478bdstevel@tonic-gate	} _p;
2727c478bdstevel@tonic-gate} lloff_t;
2737c478bdstevel@tonic-gate#endif
2747c478bdstevel@tonic-gate
2757c478bdstevel@tonic-gate#ifdef _LONG_LONG_LTOH
2767c478bdstevel@tonic-gatetypedef union {
2777c478bdstevel@tonic-gate	longlong_t	_f;	/* Full 64 bit disk address value */
2787c478bdstevel@tonic-gate	struct {
2797c478bdstevel@tonic-gate		int32_t	_l;	/* lower 32 bits of disk address value */
2807c478bdstevel@tonic-gate		int32_t	_u;	/* upper 32 bits of disk address value */
2817c478bdstevel@tonic-gate	} _p;
2827c478bdstevel@tonic-gate} lldaddr_t;
2837c478bdstevel@tonic-gate#endif
2847c478bdstevel@tonic-gate
2857c478bdstevel@tonic-gate#ifdef _LONG_LONG_HTOL
2867c478bdstevel@tonic-gatetypedef union {
2877c478bdstevel@tonic-gate	longlong_t	_f;	/* Full 64 bit disk address value */
2887c478bdstevel@tonic-gate	struct {
2897c478bdstevel@tonic-gate		int32_t	_u;	/* upper 32 bits of disk address value */
2907c478bdstevel@tonic-gate		int32_t	_l;	/* lower 32 bits of disk address value */
2917c478bdstevel@tonic-gate	} _p;
2927c478bdstevel@tonic-gate} lldaddr_t;
2937c478bdstevel@tonic-gate#endif
2947c478bdstevel@tonic-gate
2957c478bdstevel@tonic-gatetypedef uint_t k_fltset_t;	/* kernel fault set type */
2967c478bdstevel@tonic-gate
2977c478bdstevel@tonic-gate/*
2987c478bdstevel@tonic-gate * The following type is for various kinds of identifiers.  The
2997c478bdstevel@tonic-gate * actual type must be the same for all since some system calls
3007c478bdstevel@tonic-gate * (such as sigsend) take arguments that may be any of these
3017c478bdstevel@tonic-gate * types.  The enumeration type idtype_t defined in sys/procset.h
3027c478bdstevel@tonic-gate * is used to indicate what type of id is being specified --
3037c478bdstevel@tonic-gate * a process id, process group id, session id, scheduling class id,
3047c478bdstevel@tonic-gate * user id, group id, project id, task id or zone id.
3057c478bdstevel@tonic-gate */
3067c478bdstevel@tonic-gate#if defined(_LP64) || defined(_I32LPx)
3077c478bdstevel@tonic-gatetypedef int		id_t;
3087c478bdstevel@tonic-gate#else
3097c478bdstevel@tonic-gatetypedef	long		id_t;		/* (historical version) */
3107c478bdstevel@tonic-gate#endif
3117c478bdstevel@tonic-gate
3122cb2712aguzovsktypedef id_t		lgrp_id_t;	/* lgroup ID */
3132cb2712aguzovsk
3147c478bdstevel@tonic-gate/*
3157c478bdstevel@tonic-gate * Type useconds_t is an unsigned integral type capable of storing
3167c478bdstevel@tonic-gate * values at least in the range of zero to 1,000,000.
3177c478bdstevel@tonic-gate */
3187c478bdstevel@tonic-gatetypedef uint_t		useconds_t;	/* Time, in microseconds */
3197c478bdstevel@tonic-gate
3207c478bdstevel@tonic-gate#ifndef	_SUSECONDS_T
3217c478bdstevel@tonic-gate#define	_SUSECONDS_T
3227c478bdstevel@tonic-gatetypedef long	suseconds_t;	/* signed # of microseconds */
3237c478bdstevel@tonic-gate#endif	/* _SUSECONDS_T */
3247c478bdstevel@tonic-gate
3257c478bdstevel@tonic-gate/*
3267c478bdstevel@tonic-gate * Typedefs for dev_t components.
3277c478bdstevel@tonic-gate */
3287c478bdstevel@tonic-gate#if defined(_LP64) || defined(_I32LPx)
3297c478bdstevel@tonic-gatetypedef uint_t	major_t;	/* major part of device number */
3307c478bdstevel@tonic-gatetypedef uint_t	minor_t;	/* minor part of device number */
3317c478bdstevel@tonic-gate#else
3327c478bdstevel@tonic-gatetypedef ulong_t	major_t;	/* (historical version) */
3337c478bdstevel@tonic-gatetypedef ulong_t	minor_t;	/* (historical version) */
3347c478bdstevel@tonic-gate#endif
3357c478bdstevel@tonic-gate
3367c478bdstevel@tonic-gate/*
3377c478bdstevel@tonic-gate * The data type of a thread priority.
3387c478bdstevel@tonic-gate */
3397c478bdstevel@tonic-gatetypedef short	pri_t;
3407c478bdstevel@tonic-gate
3417c478bdstevel@tonic-gate/*
3427c478bdstevel@tonic-gate * The data type for a CPU flags field.  (Can be extended to larger unsigned
3437c478bdstevel@tonic-gate * types, if needed, limited by ability to update atomically.)
3447c478bdstevel@tonic-gate */
3457c478bdstevel@tonic-gatetypedef ushort_t	cpu_flag_t;
3467c478bdstevel@tonic-gate
3477c478bdstevel@tonic-gate/*
3487c478bdstevel@tonic-gate * For compatibility reasons the following typedefs (prefixed o_)
3497c478bdstevel@tonic-gate * can't grow regardless of the EFT definition. Although,
3507c478bdstevel@tonic-gate * applications should not explicitly use these typedefs
3517c478bdstevel@tonic-gate * they may be included via a system header definition.
3527c478bdstevel@tonic-gate * WARNING: These typedefs may be removed in a future
3537c478bdstevel@tonic-gate * release.
3547c478bdstevel@tonic-gate *		ex. the definitions in s5inode.h (now obsoleted)
3557c478bdstevel@tonic-gate *			remained small to preserve compatibility
3567c478bdstevel@tonic-gate *			in the S5 file system type.
3577c478bdstevel@tonic-gate */
3587c478bdstevel@tonic-gatetypedef	ushort_t o_mode_t;		/* old file attribute type */
3597c478bdstevel@tonic-gatetypedef short	o_dev_t;		/* old device type	*/
3607c478bdstevel@tonic-gatetypedef	ushort_t o_uid_t;		/* old UID type		*/
3617c478bdstevel@tonic-gatetypedef	o_uid_t	o_gid_t;		/* old GID type		*/
3627c478bdstevel@tonic-gatetypedef	short	o_nlink_t;		/* old file link type	*/
3637c478bdstevel@tonic-gatetypedef short	o_pid_t;		/* old process id type	*/
3647c478bdstevel@tonic-gatetypedef ushort_t o_ino_t;		/* old inode type	*/
3657c478bdstevel@tonic-gate
3667c478bdstevel@tonic-gate
3677c478bdstevel@tonic-gate/*
3687c478bdstevel@tonic-gate * POSIX and XOPEN Declarations
3697c478bdstevel@tonic-gate */
3707c478bdstevel@tonic-gatetypedef	int	key_t;			/* IPC key type		*/
3717c478bdstevel@tonic-gate#if defined(_LP64) || defined(_I32LPx)
3727c478bdstevel@tonic-gatetypedef	uint_t	mode_t;			/* file attribute type	*/
3737c478bdstevel@tonic-gate#else
3747c478bdstevel@tonic-gatetypedef	ulong_t	mode_t;			/* (historical version) */
3757c478bdstevel@tonic-gate#endif
3767c478bdstevel@tonic-gate
3777c478bdstevel@tonic-gate#ifndef	_UID_T
3787c478bdstevel@tonic-gate#define	_UID_T
379f48205bcaspertypedef	unsigned int uid_t;		/* UID type		*/
3807c478bdstevel@tonic-gate#endif	/* _UID_T */
3817c478bdstevel@tonic-gate
3827c478bdstevel@tonic-gatetypedef	uid_t	gid_t;			/* GID type		*/
3837c478bdstevel@tonic-gate
384b6b50fcNitin Handetypedef uint32_t	datalink_id_t;
3851cb875aCathy Zhoutypedef	uint32_t	vrid_t;
386b6b50fcNitin Hande
3877c478bdstevel@tonic-gatetypedef id_t    taskid_t;
3887c478bdstevel@tonic-gatetypedef id_t    projid_t;
3897c478bdstevel@tonic-gatetypedef	id_t	poolid_t;
3907c478bdstevel@tonic-gatetypedef id_t	zoneid_t;
3917c478bdstevel@tonic-gatetypedef id_t	ctid_t;
3927c478bdstevel@tonic-gate
3937c478bdstevel@tonic-gate/*
3947c478bdstevel@tonic-gate * POSIX definitions are same as defined in thread.h and synch.h.
3957c478bdstevel@tonic-gate * Any changes made to here should be reflected in corresponding
3967c478bdstevel@tonic-gate * files as described in comments.
3977c478bdstevel@tonic-gate */
3987c478bdstevel@tonic-gatetypedef	uint_t	pthread_t;	/* = thread_t in thread.h */
3997c478bdstevel@tonic-gatetypedef	uint_t	pthread_key_t;	/* = thread_key_t in thread.h */
4007c478bdstevel@tonic-gate
4017c478bdstevel@tonic-gate/* "Magic numbers" tagging synchronization object types */
4027c478bdstevel@tonic-gate#define	_MUTEX_MAGIC	0x4d58		/* "MX" */
4037c478bdstevel@tonic-gate#define	_SEMA_MAGIC	0x534d		/* "SM" */
4047c478bdstevel@tonic-gate#define	_COND_MAGIC	0x4356		/* "CV" */
4057c478bdstevel@tonic-gate#define	_RWL_MAGIC	0x5257		/* "RW" */
4067c478bdstevel@tonic-gate
4077c478bdstevel@tonic-gatetypedef	struct _pthread_mutex {		/* = mutex_t in synch.h */
4087c478bdstevel@tonic-gate	struct {
4097c478bdstevel@tonic-gate		uint16_t	__pthread_mutex_flag1;
4107c478bdstevel@tonic-gate		uint8_t		__pthread_mutex_flag2;
4117c478bdstevel@tonic-gate		uint8_t		__pthread_mutex_ceiling;
4127c478bdstevel@tonic-gate		uint16_t 	__pthread_mutex_type;
4137c478bdstevel@tonic-gate		uint16_t 	__pthread_mutex_magic;
4147c478bdstevel@tonic-gate	} __pthread_mutex_flags;
4157c478bdstevel@tonic-gate	union {
4167c478bdstevel@tonic-gate		struct {
4177c478bdstevel@tonic-gate			uint8_t	__pthread_mutex_pad[8];
4187c478bdstevel@tonic-gate		} __pthread_mutex_lock64;
4197c478bdstevel@tonic-gate		struct {
4207c478bdstevel@tonic-gate			uint32_t __pthread_ownerpid;
4217c478bdstevel@tonic-gate			uint32_t __pthread_lockword;
4227c478bdstevel@tonic-gate		} __pthread_mutex_lock32;
4237c478bdstevel@tonic-gate		upad64_t __pthread_mutex_owner64;
4247c478bdstevel@tonic-gate	} __pthread_mutex_lock;
4257c478bdstevel@tonic-gate	upad64_t __pthread_mutex_data;
4267c478bdstevel@tonic-gate} pthread_mutex_t;
4277c478bdstevel@tonic-gate
4287c478bdstevel@tonic-gatetypedef	struct _pthread_cond {		/* = cond_t in synch.h */
4297c478bdstevel@tonic-gate	struct {
4307c478bdstevel@tonic-gate		uint8_t		__pthread_cond_flag[4];
4317c478bdstevel@tonic-gate		uint16_t 	__pthread_cond_type;
4327c478bdstevel@tonic-gate		uint16_t 	__pthread_cond_magic;
4337c478bdstevel@tonic-gate	} __pthread_cond_flags;
4347c478bdstevel@tonic-gate	upad64_t __pthread_cond_data;
4357c478bdstevel@tonic-gate} pthread_cond_t;
4367c478bdstevel@tonic-gate
4377c478bdstevel@tonic-gate/*
4387c478bdstevel@tonic-gate * UNIX 98 Extension
4397c478bdstevel@tonic-gate */
4407c478bdstevel@tonic-gatetypedef	struct _pthread_rwlock {	/* = rwlock_t in synch.h */
4417c478bdstevel@tonic-gate	int32_t		__pthread_rwlock_readers;
4427c478bdstevel@tonic-gate	uint16_t	__pthread_rwlock_type;
4437c478bdstevel@tonic-gate	uint16_t	__pthread_rwlock_magic;
4447c478bdstevel@tonic-gate	pthread_mutex_t	__pthread_rwlock_mutex;
4457c478bdstevel@tonic-gate	pthread_cond_t	__pthread_rwlock_readercv;
4467c478bdstevel@tonic-gate	pthread_cond_t	__pthread_rwlock_writercv;
4477c478bdstevel@tonic-gate} pthread_rwlock_t;
4487c478bdstevel@tonic-gate
4497c478bdstevel@tonic-gate/*
4507c478bdstevel@tonic-gate * SUSV3
4517c478bdstevel@tonic-gate */
4527c478bdstevel@tonic-gatetypedef struct {
4537c478bdstevel@tonic-gate	uint32_t	__pthread_barrier_count;
4547c478bdstevel@tonic-gate	uint32_t	__pthread_barrier_current;
4557c478bdstevel@tonic-gate	upad64_t	__pthread_barrier_cycle;
4567c478bdstevel@tonic-gate	upad64_t	__pthread_barrier_reserved;
4577c478bdstevel@tonic-gate	pthread_mutex_t	__pthread_barrier_lock;
4587c478bdstevel@tonic-gate	pthread_cond_t	__pthread_barrier_cond;
4597c478bdstevel@tonic-gate} pthread_barrier_t;
4607c478bdstevel@tonic-gate
4617c478bdstevel@tonic-gatetypedef	pthread_mutex_t	pthread_spinlock_t;
4627c478bdstevel@tonic-gate
4637c478bdstevel@tonic-gate/*
4647c478bdstevel@tonic-gate * attributes for threads, dynamically allocated by library
4657c478bdstevel@tonic-gate */
4667c478bdstevel@tonic-gatetypedef struct _pthread_attr {
4677c478bdstevel@tonic-gate	void	*__pthread_attrp;
4687c478bdstevel@tonic-gate} pthread_attr_t;
4697c478bdstevel@tonic-gate
4707c478bdstevel@tonic-gate/*
4717c478bdstevel@tonic-gate * attributes for mutex, dynamically allocated by library
4727c478bdstevel@tonic-gate */
4737c478bdstevel@tonic-gatetypedef struct _pthread_mutexattr {
4747c478bdstevel@tonic-gate	void	*__pthread_mutexattrp;
4757c478bdstevel@tonic-gate} pthread_mutexattr_t;
4767c478bdstevel@tonic-gate
4777c478bdstevel@tonic-gate/*
4787c478bdstevel@tonic-gate * attributes for cond, dynamically allocated by library
4797c478bdstevel@tonic-gate */
4807c478bdstevel@tonic-gatetypedef struct _pthread_condattr {
4817c478bdstevel@tonic-gate	void	*__pthread_condattrp;
4827c478bdstevel@tonic-gate} pthread_condattr_t;
4837c478bdstevel@tonic-gate
4847c478bdstevel@tonic-gate/*
4857c478bdstevel@tonic-gate * pthread_once
4867c478bdstevel@tonic-gate */
4877c478bdstevel@tonic-gatetypedef	struct _once {
4887c478bdstevel@tonic-gate	upad64_t	__pthread_once_pad[4];
4897c478bdstevel@tonic-gate} pthread_once_t;
4907c478bdstevel@tonic-gate
4917c478bdstevel@tonic-gate/*
4927c478bdstevel@tonic-gate * UNIX 98 Extensions
4937c478bdstevel@tonic-gate * attributes for rwlock, dynamically allocated by library
4947c478bdstevel@tonic-gate */
4957c478bdstevel@tonic-gatetypedef struct _pthread_rwlockattr {
4967c478bdstevel@tonic-gate	void	*__pthread_rwlockattrp;
4977c478bdstevel@tonic-gate} pthread_rwlockattr_t;
4987c478bdstevel@tonic-gate
4997c478bdstevel@tonic-gate/*
5007c478bdstevel@tonic-gate * SUSV3
5017c478bdstevel@tonic-gate * attributes for pthread_barrier_t, dynamically allocated by library
5027c478bdstevel@tonic-gate */
5037c478bdstevel@tonic-gatetypedef struct {
5047c478bdstevel@tonic-gate	void	*__pthread_barrierattrp;
5057c478bdstevel@tonic-gate} pthread_barrierattr_t;
5067c478bdstevel@tonic-gate
5077c478bdstevel@tonic-gatetypedef ulong_t	dev_t;			/* expanded device type */
5087c478bdstevel@tonic-gate
5097c478bdstevel@tonic-gate#if defined(_LP64) || defined(_I32LPx)
5107c478bdstevel@tonic-gatetypedef	uint_t nlink_t;			/* file link type	*/
5117c478bdstevel@tonic-gatetypedef int	pid_t;			/* process id type	*/
5127c478bdstevel@tonic-gate#else
5137c478bdstevel@tonic-gatetypedef	ulong_t	nlink_t;		/* (historical version) */
5147c478bdstevel@tonic-gatetypedef	long	pid_t;			/* (historical version) */
5157c478bdstevel@tonic-gate#endif
5167c478bdstevel@tonic-gate
5177c478bdstevel@tonic-gate#if !defined(_SIZE_T) || __cplusplus >= 199711L
5187c478bdstevel@tonic-gate#define	_SIZE_T
5197c478bdstevel@tonic-gate#if defined(_LP64) || defined(_I32LPx)
5207c478bdstevel@tonic-gatetypedef	ulong_t	size_t;		/* size of something in bytes */
5217c478bdstevel@tonic-gate#else
5227c478bdstevel@tonic-gatetypedef	uint_t	size_t;		/* (historical version) */
5237c478bdstevel@tonic-gate#endif
5247c478bdstevel@tonic-gate#endif	/* _SIZE_T */
5257c478bdstevel@tonic-gate
5267c478bdstevel@tonic-gate#ifndef _SSIZE_T
5277c478bdstevel@tonic-gate#define	_SSIZE_T
5287c478bdstevel@tonic-gate#if defined(_LP64) || defined(_I32LPx)
5297c478bdstevel@tonic-gatetypedef long	ssize_t;	/* size of something in bytes or -1 */
5307c478bdstevel@tonic-gate#else
5317c478bdstevel@tonic-gatetypedef int	ssize_t;	/* (historical version) */
5327c478bdstevel@tonic-gate#endif
5337c478bdstevel@tonic-gate#endif	/* _SSIZE_T */
5347c478bdstevel@tonic-gate
5357c478bdstevel@tonic-gate#if !defined(_TIME_T) || __cplusplus >= 199711L
5367c478bdstevel@tonic-gate#define	_TIME_T
5377c478bdstevel@tonic-gatetypedef	long		time_t;	/* time of day in seconds */
5387c478bdstevel@tonic-gate#endif	/* _TIME_T */
5397c478bdstevel@tonic-gate
5407c478bdstevel@tonic-gate#if !defined(_CLOCK_T) || __cplusplus >= 199711L
5417c478bdstevel@tonic-gate#define	_CLOCK_T
5427c478bdstevel@tonic-gatetypedef	long		clock_t; /* relative time in a specified resolution */
5437c478bdstevel@tonic-gate#endif	/* ifndef _CLOCK_T */
5447c478bdstevel@tonic-gate
5457c478bdstevel@tonic-gate#ifndef _CLOCKID_T
5467c478bdstevel@tonic-gate#define	_CLOCKID_T
5477c478bdstevel@tonic-gatetypedef	int	clockid_t;	/* clock identifier type */
5487c478bdstevel@tonic-gate#endif	/* ifndef _CLOCKID_T */
5497c478bdstevel@tonic-gate
5507c478bdstevel@tonic-gate#ifndef _TIMER_T
5517c478bdstevel@tonic-gate#define	_TIMER_T
5527c478bdstevel@tonic-gatetypedef	int	timer_t;	/* timer identifier type */
5537c478bdstevel@tonic-gate#endif	/* ifndef _TIMER_T */
5547c478bdstevel@tonic-gate
5557c478bdstevel@tonic-gate#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
5567c478bdstevel@tonic-gate
5577c478bdstevel@tonic-gate/* BEGIN CSTYLED */
5587c478bdstevel@tonic-gatetypedef	unsigned char	unchar;
5597c478bdstevel@tonic-gatetypedef	unsigned short	ushort;
5607c478bdstevel@tonic-gatetypedef	unsigned int	uint;
5617c478bdstevel@tonic-gatetypedef	unsigned long	ulong;
5627c478bdstevel@tonic-gate/* END CSTYLED */
5637c478bdstevel@tonic-gate
564b819ceaGordon Ross#if defined(_KERNEL) || defined(_FAKE_KERNEL)
5657c478bdstevel@tonic-gate
5667c478bdstevel@tonic-gate#define	SHRT_MIN	(-32768)	/* min value of a "short int" */
5677c478bdstevel@tonic-gate#define	SHRT_MAX	32767		/* max value of a "short int" */
5687c478bdstevel@tonic-gate#define	USHRT_MAX	65535		/* max of "unsigned short int" */
5697c478bdstevel@tonic-gate#define	INT_MIN		(-2147483647-1) /* min value of an "int" */
5707c478bdstevel@tonic-gate#define	INT_MAX		2147483647	/* max value of an "int" */
5717c478bdstevel@tonic-gate#define	UINT_MAX	4294967295U	/* max value of an "unsigned int" */
5727c478bdstevel@tonic-gate#if defined(_LP64)
5737c478bdstevel@tonic-gate#define	LONG_MIN	(-9223372036854775807L-1L)
5747c478bdstevel@tonic-gate					/* min value of a "long int" */
5757c478bdstevel@tonic-gate#define	LONG_MAX	9223372036854775807L
5767c478bdstevel@tonic-gate					/* max value of a "long int" */
5777c478bdstevel@tonic-gate#define	ULONG_MAX	18446744073709551615UL
5787c478bdstevel@tonic-gate					/* max of "unsigned long int" */
5797c478bdstevel@tonic-gate#else /* _ILP32 */
5807c478bdstevel@tonic-gate#define	LONG_MIN	(-2147483647L-1L)
5817c478bdstevel@tonic-gate					/* min value of a "long int" */
5827c478bdstevel@tonic-gate#define	LONG_MAX	2147483647L	/* max value of a "long int" */
5837c478bdstevel@tonic-gate#define	ULONG_MAX	4294967295UL	/* max of "unsigned long int" */
5847c478bdstevel@tonic-gate#endif
5857c478bdstevel@tonic-gate
5862ef9abdjv#define	LLONG_MIN	(-9223372036854775807LL-1LL)
5872ef9abdjv					/* min of "long long int" */
5882ef9abdjv#define	LLONG_MAX	9223372036854775807LL
5892ef9abdjv					/* max of "long long int" */
5902ef9abdjv#define	ULLONG_MAX	18446744073709551615ULL
5912ef9abdjv					/* max of "unsigned long long int" */
5922ef9abdjv
5931f0c5e6Robert Mustacchi#if defined(_LP64) || _FILE_OFFSET_BITS == 32
5941f0c5e6Robert Mustacchi#define	OFF_MIN		LONG_MIN
5951f0c5e6Robert Mustacchi#define	OFF_MAX		LONG_MAX
5961f0c5e6Robert Mustacchi#elif _FILE_OFFSET_BITS == 64
5971f0c5e6Robert Mustacchi#define	OFF_MIN		LLONG_MIN
5981f0c5e6Robert Mustacchi#define	OFF_MAX		LLONG_MAX
5991f0c5e6Robert Mustacchi#endif	/* _LP64 || _FILE_OFFSET_BITS == 32 */
6001f0c5e6Robert Mustacchi
6017c478bdstevel@tonic-gate#endif	/* defined(_KERNEL) */
6027c478bdstevel@tonic-gate
6037c478bdstevel@tonic-gate#define	P_MYPID	((pid_t)0)
6047c478bdstevel@tonic-gate
6057c478bdstevel@tonic-gate/*
6067c478bdstevel@tonic-gate * The following is the value of type id_t to use to indicate the
6077c478bdstevel@tonic-gate * caller's current id.  See procset.h for the type idtype_t
6087c478bdstevel@tonic-gate * which defines which kind of id is being specified.
6097c478bdstevel@tonic-gate */
6107c478bdstevel@tonic-gate#define	P_MYID	(-1)
6117c478bdstevel@tonic-gate#define	NOPID (pid_t)(-1)
6127c478bdstevel@tonic-gate
6137c478bdstevel@tonic-gate#ifndef NODEV
6147c478bdstevel@tonic-gate#define	NODEV	(dev_t)(-1l)
6157c478bdstevel@tonic-gate#ifdef _SYSCALL32
6167c478bdstevel@tonic-gate#define	NODEV32	(dev32_t)(-1)
6177c478bdstevel@tonic-gate#endif	/* _SYSCALL32 */
6187c478bdstevel@tonic-gate#endif	/* NODEV */
6197c478bdstevel@tonic-gate
6207c478bdstevel@tonic-gate/*
6217c478bdstevel@tonic-gate * The following value of type pfn_t is used to indicate
6227c478bdstevel@tonic-gate * invalid page frame number.
6237c478bdstevel@tonic-gate */
6247c478bdstevel@tonic-gate#define	PFN_INVALID	((pfn_t)-1)
6257c478bdstevel@tonic-gate#define	PFN_SUSPENDED	((pfn_t)-2)
6267c478bdstevel@tonic-gate
6277c478bdstevel@tonic-gate/* BEGIN CSTYLED */
6287c478bdstevel@tonic-gatetypedef unsigned char	u_char;
6297c478bdstevel@tonic-gatetypedef unsigned short	u_short;
6307c478bdstevel@tonic-gatetypedef unsigned int	u_int;
6317c478bdstevel@tonic-gatetypedef unsigned long	u_long;
6327c478bdstevel@tonic-gatetypedef struct _quad { int val[2]; } quad_t;	/* used by UFS */
6337c478bdstevel@tonic-gatetypedef quad_t		quad;			/* used by UFS */
6347c478bdstevel@tonic-gate/* END CSTYLED */
6357c478bdstevel@tonic-gate
6367c478bdstevel@tonic-gate/*
6377c478bdstevel@tonic-gate * Nested include for BSD/sockets source compatibility.
6387c478bdstevel@tonic-gate * (The select macros used to be defined here).
6397c478bdstevel@tonic-gate */
6407c478bdstevel@tonic-gate#include <sys/select.h>
6417c478bdstevel@tonic-gate
6427c478bdstevel@tonic-gate#endif	/* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
6437c478bdstevel@tonic-gate
6447c478bdstevel@tonic-gate/*
6457c478bdstevel@tonic-gate * _VOID was defined to be either void or char but this is not
6467c478bdstevel@tonic-gate * required because previous SunOS compilers have accepted the void
6477c478bdstevel@tonic-gate * type. However, because many system header and source files use the
6487c478bdstevel@tonic-gate * void keyword, the volatile keyword, and ANSI C function prototypes,
6497c478bdstevel@tonic-gate * non-ANSI compilers cannot compile the system anyway. The _VOID macro
6507c478bdstevel@tonic-gate * should therefore not be used and remains for source compatibility
6517c478bdstevel@tonic-gate * only.
6527c478bdstevel@tonic-gate */
6537c478bdstevel@tonic-gate/* CSTYLED */
6547c478bdstevel@tonic-gate#define	_VOID	void
6557c478bdstevel@tonic-gate
6567c478bdstevel@tonic-gate#ifdef	__cplusplus
6577c478bdstevel@tonic-gate}
6587c478bdstevel@tonic-gate#endif
6597c478bdstevel@tonic-gate
6607c478bdstevel@tonic-gate#endif	/* _SYS_TYPES_H */
661