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