xref: /illumos-gate/usr/src/boot/sys/sys/types.h (revision 9890ff83)
1199767f8SToomas Soome /*-
2199767f8SToomas Soome  * Copyright (c) 1982, 1986, 1991, 1993, 1994
3199767f8SToomas Soome  *	The Regents of the University of California.  All rights reserved.
4199767f8SToomas Soome  * (c) UNIX System Laboratories, Inc.
5199767f8SToomas Soome  * All or some portions of this file are derived from material licensed
6199767f8SToomas Soome  * to the University of California by American Telephone and Telegraph
7199767f8SToomas Soome  * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8199767f8SToomas Soome  * the permission of UNIX System Laboratories, Inc.
9199767f8SToomas Soome  *
10199767f8SToomas Soome  * Redistribution and use in source and binary forms, with or without
11199767f8SToomas Soome  * modification, are permitted provided that the following conditions
12199767f8SToomas Soome  * are met:
13199767f8SToomas Soome  * 1. Redistributions of source code must retain the above copyright
14199767f8SToomas Soome  *    notice, this list of conditions and the following disclaimer.
15199767f8SToomas Soome  * 2. Redistributions in binary form must reproduce the above copyright
16199767f8SToomas Soome  *    notice, this list of conditions and the following disclaimer in the
17199767f8SToomas Soome  *    documentation and/or other materials provided with the distribution.
18199767f8SToomas Soome  * 4. Neither the name of the University nor the names of its contributors
19199767f8SToomas Soome  *    may be used to endorse or promote products derived from this software
20199767f8SToomas Soome  *    without specific prior written permission.
21199767f8SToomas Soome  *
22199767f8SToomas Soome  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23199767f8SToomas Soome  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24199767f8SToomas Soome  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25199767f8SToomas Soome  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26199767f8SToomas Soome  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27199767f8SToomas Soome  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28199767f8SToomas Soome  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29199767f8SToomas Soome  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30199767f8SToomas Soome  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31199767f8SToomas Soome  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32199767f8SToomas Soome  * SUCH DAMAGE.
33199767f8SToomas Soome  *
34199767f8SToomas Soome  *	@(#)types.h	8.6 (Berkeley) 2/19/95
35199767f8SToomas Soome  * $FreeBSD$
36199767f8SToomas Soome  */
37199767f8SToomas Soome 
38199767f8SToomas Soome #ifndef _SYS_TYPES_H_
39199767f8SToomas Soome #define	_SYS_TYPES_H_
40199767f8SToomas Soome 
41199767f8SToomas Soome #include <sys/cdefs.h>
42199767f8SToomas Soome 
43199767f8SToomas Soome /* Machine type dependent parameters. */
44199767f8SToomas Soome #include <machine/endian.h>
45199767f8SToomas Soome #include <sys/_types.h>
46199767f8SToomas Soome 
47199767f8SToomas Soome #include <sys/_pthreadtypes.h>
48199767f8SToomas Soome 
49199767f8SToomas Soome #if __BSD_VISIBLE
50199767f8SToomas Soome typedef	unsigned char	u_char;
51199767f8SToomas Soome typedef	unsigned short	u_short;
52199767f8SToomas Soome typedef	unsigned int	u_int;
53199767f8SToomas Soome typedef	unsigned long	u_long;
54199767f8SToomas Soome #ifndef _KERNEL
55199767f8SToomas Soome typedef	unsigned short	ushort;		/* Sys V compatibility */
56199767f8SToomas Soome typedef	unsigned int	uint;		/* Sys V compatibility */
57199767f8SToomas Soome #endif
58199767f8SToomas Soome #endif
59199767f8SToomas Soome 
604a04e8dbSToomas Soome /*
614a04e8dbSToomas Soome  * POSIX Extensions
624a04e8dbSToomas Soome  */
63734b3a42SToomas Soome typedef	unsigned char	uchar_t;
64734b3a42SToomas Soome typedef	unsigned short	ushort_t;
654a04e8dbSToomas Soome typedef	unsigned int	uint_t;
66734b3a42SToomas Soome typedef	unsigned long	ulong_t;
674a04e8dbSToomas Soome 
68199767f8SToomas Soome /*
69199767f8SToomas Soome  * XXX POSIX sized integrals that should appear only in <sys/stdint.h>.
70199767f8SToomas Soome  */
71199767f8SToomas Soome #include <sys/_stdint.h>
72199767f8SToomas Soome 
73199767f8SToomas Soome typedef __uint8_t	u_int8_t;	/* unsigned integrals (deprecated) */
74199767f8SToomas Soome typedef __uint16_t	u_int16_t;
75199767f8SToomas Soome typedef __uint32_t	u_int32_t;
76199767f8SToomas Soome typedef __uint64_t	u_int64_t;
77199767f8SToomas Soome 
78199767f8SToomas Soome typedef	__uint64_t	u_quad_t;	/* quads (deprecated) */
79199767f8SToomas Soome typedef	__int64_t	quad_t;
80199767f8SToomas Soome typedef	quad_t *	qaddr_t;
81199767f8SToomas Soome 
82199767f8SToomas Soome typedef	char *		caddr_t;	/* core address */
83199767f8SToomas Soome typedef	const char *	c_caddr_t;	/* core address, pointer to const */
84199767f8SToomas Soome 
85199767f8SToomas Soome #ifndef _BLKSIZE_T_DECLARED
86199767f8SToomas Soome typedef	__blksize_t	blksize_t;
87199767f8SToomas Soome #define	_BLKSIZE_T_DECLARED
88199767f8SToomas Soome #endif
89199767f8SToomas Soome 
90199767f8SToomas Soome typedef	__cpuwhich_t	cpuwhich_t;
91199767f8SToomas Soome typedef	__cpulevel_t	cpulevel_t;
92199767f8SToomas Soome typedef	__cpusetid_t	cpusetid_t;
93199767f8SToomas Soome 
94199767f8SToomas Soome #ifndef _BLKCNT_T_DECLARED
95199767f8SToomas Soome typedef	__blkcnt_t	blkcnt_t;
96199767f8SToomas Soome #define	_BLKCNT_T_DECLARED
97199767f8SToomas Soome #endif
98199767f8SToomas Soome 
99199767f8SToomas Soome #ifndef _CLOCK_T_DECLARED
100199767f8SToomas Soome typedef	__clock_t	clock_t;
101199767f8SToomas Soome #define	_CLOCK_T_DECLARED
102199767f8SToomas Soome #endif
103199767f8SToomas Soome 
104199767f8SToomas Soome #ifndef _CLOCKID_T_DECLARED
105199767f8SToomas Soome typedef	__clockid_t	clockid_t;
106199767f8SToomas Soome #define	_CLOCKID_T_DECLARED
107199767f8SToomas Soome #endif
108199767f8SToomas Soome 
109199767f8SToomas Soome typedef	__critical_t	critical_t;	/* Critical section value */
110199767f8SToomas Soome typedef	__int64_t	daddr_t;	/* disk address */
111199767f8SToomas Soome 
112199767f8SToomas Soome #ifndef _DEV_T_DECLARED
113199767f8SToomas Soome typedef	__dev_t		dev_t;		/* device number or struct cdev */
114199767f8SToomas Soome #define	_DEV_T_DECLARED
115199767f8SToomas Soome #endif
116199767f8SToomas Soome 
117199767f8SToomas Soome #ifndef _FFLAGS_T_DECLARED
118199767f8SToomas Soome typedef	__fflags_t	fflags_t;	/* file flags */
119199767f8SToomas Soome #define	_FFLAGS_T_DECLARED
120199767f8SToomas Soome #endif
121199767f8SToomas Soome 
122199767f8SToomas Soome typedef	__fixpt_t	fixpt_t;	/* fixed point number */
123199767f8SToomas Soome 
124199767f8SToomas Soome #ifndef _FSBLKCNT_T_DECLARED		/* for statvfs() */
125199767f8SToomas Soome typedef	__fsblkcnt_t	fsblkcnt_t;
126199767f8SToomas Soome typedef	__fsfilcnt_t	fsfilcnt_t;
127199767f8SToomas Soome #define	_FSBLKCNT_T_DECLARED
128199767f8SToomas Soome #endif
129199767f8SToomas Soome 
130199767f8SToomas Soome #ifndef _GID_T_DECLARED
131199767f8SToomas Soome typedef	__gid_t		gid_t;		/* group id */
132199767f8SToomas Soome #define	_GID_T_DECLARED
133199767f8SToomas Soome #endif
134199767f8SToomas Soome 
135199767f8SToomas Soome #ifndef _IN_ADDR_T_DECLARED
136199767f8SToomas Soome typedef	__uint32_t	in_addr_t;	/* base type for internet address */
137199767f8SToomas Soome #define	_IN_ADDR_T_DECLARED
138199767f8SToomas Soome #endif
139199767f8SToomas Soome 
140199767f8SToomas Soome #ifndef _IN_PORT_T_DECLARED
141199767f8SToomas Soome typedef	__uint16_t	in_port_t;
142199767f8SToomas Soome #define	_IN_PORT_T_DECLARED
143199767f8SToomas Soome #endif
144199767f8SToomas Soome 
145199767f8SToomas Soome #ifndef _ID_T_DECLARED
146199767f8SToomas Soome typedef	__id_t		id_t;		/* can hold a uid_t or pid_t */
147199767f8SToomas Soome #define	_ID_T_DECLARED
148199767f8SToomas Soome #endif
149199767f8SToomas Soome 
150199767f8SToomas Soome #ifndef _INO_T_DECLARED
151199767f8SToomas Soome typedef	__ino_t		ino_t;		/* inode number */
152199767f8SToomas Soome #define	_INO_T_DECLARED
153199767f8SToomas Soome #endif
154199767f8SToomas Soome 
155199767f8SToomas Soome #ifndef _KEY_T_DECLARED
156199767f8SToomas Soome typedef	__key_t		key_t;		/* IPC key (for Sys V IPC) */
157199767f8SToomas Soome #define	_KEY_T_DECLARED
158199767f8SToomas Soome #endif
159199767f8SToomas Soome 
160199767f8SToomas Soome #ifndef _LWPID_T_DECLARED
161199767f8SToomas Soome typedef	__lwpid_t	lwpid_t;	/* Thread ID (a.k.a. LWP) */
162199767f8SToomas Soome #define	_LWPID_T_DECLARED
163199767f8SToomas Soome #endif
164199767f8SToomas Soome 
165199767f8SToomas Soome #ifndef _MODE_T_DECLARED
166199767f8SToomas Soome typedef	__mode_t	mode_t;		/* permissions */
167199767f8SToomas Soome #define	_MODE_T_DECLARED
168199767f8SToomas Soome #endif
169199767f8SToomas Soome 
170199767f8SToomas Soome #ifndef _ACCMODE_T_DECLARED
171199767f8SToomas Soome typedef	__accmode_t	accmode_t;	/* access permissions */
172199767f8SToomas Soome #define	_ACCMODE_T_DECLARED
173199767f8SToomas Soome #endif
174199767f8SToomas Soome 
175199767f8SToomas Soome #ifndef _NLINK_T_DECLARED
176199767f8SToomas Soome typedef	__nlink_t	nlink_t;	/* link count */
177199767f8SToomas Soome #define	_NLINK_T_DECLARED
178199767f8SToomas Soome #endif
179199767f8SToomas Soome 
180199767f8SToomas Soome #ifndef _OFF_T_DECLARED
181199767f8SToomas Soome typedef	__off_t		off_t;		/* file offset */
182199767f8SToomas Soome #define	_OFF_T_DECLARED
183199767f8SToomas Soome #endif
184199767f8SToomas Soome 
185199767f8SToomas Soome #ifndef _PID_T_DECLARED
186199767f8SToomas Soome typedef	__pid_t		pid_t;		/* process id */
187199767f8SToomas Soome #define	_PID_T_DECLARED
188199767f8SToomas Soome #endif
189199767f8SToomas Soome 
190199767f8SToomas Soome typedef	__register_t	register_t;
191199767f8SToomas Soome 
192199767f8SToomas Soome #ifndef _RLIM_T_DECLARED
193199767f8SToomas Soome typedef	__rlim_t	rlim_t;		/* resource limit */
194199767f8SToomas Soome #define	_RLIM_T_DECLARED
195199767f8SToomas Soome #endif
196199767f8SToomas Soome 
197199767f8SToomas Soome typedef	__int64_t	sbintime_t;
198199767f8SToomas Soome 
199199767f8SToomas Soome typedef	__segsz_t	segsz_t;	/* segment size (in pages) */
200199767f8SToomas Soome 
201199767f8SToomas Soome #ifndef _SIZE_T_DECLARED
202199767f8SToomas Soome typedef	__size_t	size_t;
203199767f8SToomas Soome #define	_SIZE_T_DECLARED
204199767f8SToomas Soome #endif
205199767f8SToomas Soome 
206199767f8SToomas Soome #ifndef _SSIZE_T_DECLARED
207199767f8SToomas Soome typedef	__ssize_t	ssize_t;
208199767f8SToomas Soome #define	_SSIZE_T_DECLARED
209199767f8SToomas Soome #endif
210199767f8SToomas Soome 
211199767f8SToomas Soome #ifndef _SUSECONDS_T_DECLARED
212199767f8SToomas Soome typedef	__suseconds_t	suseconds_t;	/* microseconds (signed) */
213199767f8SToomas Soome #define	_SUSECONDS_T_DECLARED
214199767f8SToomas Soome #endif
215199767f8SToomas Soome 
216199767f8SToomas Soome #ifndef _TIME_T_DECLARED
217199767f8SToomas Soome typedef	__time_t	time_t;
218199767f8SToomas Soome #define	_TIME_T_DECLARED
219199767f8SToomas Soome #endif
220199767f8SToomas Soome 
221199767f8SToomas Soome #ifndef _TIMER_T_DECLARED
222199767f8SToomas Soome typedef	__timer_t	timer_t;
223199767f8SToomas Soome #define	_TIMER_T_DECLARED
224199767f8SToomas Soome #endif
225199767f8SToomas Soome 
226199767f8SToomas Soome #ifndef _MQD_T_DECLARED
227199767f8SToomas Soome typedef	__mqd_t	mqd_t;
228199767f8SToomas Soome #define	_MQD_T_DECLARED
229199767f8SToomas Soome #endif
230199767f8SToomas Soome 
231199767f8SToomas Soome typedef	__u_register_t	u_register_t;
232199767f8SToomas Soome 
233199767f8SToomas Soome #ifndef _UID_T_DECLARED
234199767f8SToomas Soome typedef	__uid_t		uid_t;		/* user id */
235199767f8SToomas Soome #define	_UID_T_DECLARED
236199767f8SToomas Soome #endif
237199767f8SToomas Soome 
238199767f8SToomas Soome #ifndef _USECONDS_T_DECLARED
239199767f8SToomas Soome typedef	__useconds_t	useconds_t;	/* microseconds (unsigned) */
240199767f8SToomas Soome #define	_USECONDS_T_DECLARED
241199767f8SToomas Soome #endif
242199767f8SToomas Soome 
243199767f8SToomas Soome #ifndef _CAP_IOCTL_T_DECLARED
244199767f8SToomas Soome #define	_CAP_IOCTL_T_DECLARED
245199767f8SToomas Soome typedef	unsigned long	cap_ioctl_t;
246199767f8SToomas Soome #endif
247199767f8SToomas Soome 
248199767f8SToomas Soome #ifndef _CAP_RIGHTS_T_DECLARED
249199767f8SToomas Soome #define	_CAP_RIGHTS_T_DECLARED
250199767f8SToomas Soome struct cap_rights;
251199767f8SToomas Soome 
252199767f8SToomas Soome typedef	struct cap_rights	cap_rights_t;
253199767f8SToomas Soome #endif
254199767f8SToomas Soome 
255199767f8SToomas Soome typedef	__vm_offset_t	vm_offset_t;
256199767f8SToomas Soome typedef	__vm_ooffset_t	vm_ooffset_t;
257199767f8SToomas Soome typedef	__vm_paddr_t	vm_paddr_t;
258199767f8SToomas Soome typedef	__vm_pindex_t	vm_pindex_t;
259199767f8SToomas Soome typedef	__vm_size_t	vm_size_t;
260199767f8SToomas Soome 
261199767f8SToomas Soome typedef __rman_res_t    rman_res_t;
262199767f8SToomas Soome 
263199767f8SToomas Soome #ifdef _KERNEL
264199767f8SToomas Soome typedef	int		boolean_t;
265199767f8SToomas Soome typedef	struct device	*device_t;
266199767f8SToomas Soome typedef	__intfptr_t	intfptr_t;
267199767f8SToomas Soome 
268199767f8SToomas Soome /*
269199767f8SToomas Soome  * XXX this is fixed width for historical reasons.  It should have had type
270199767f8SToomas Soome  * __int_fast32_t.  Fixed-width types should not be used unless binary
271199767f8SToomas Soome  * compatibility is essential.  Least-width types should be used even less
272199767f8SToomas Soome  * since they provide smaller benefits.
273199767f8SToomas Soome  *
274199767f8SToomas Soome  * XXX should be MD.
275199767f8SToomas Soome  *
276199767f8SToomas Soome  * XXX this is bogus in -current, but still used for spl*().
277199767f8SToomas Soome  */
278199767f8SToomas Soome typedef	__uint32_t	intrmask_t;	/* Interrupt mask (spl, xxx_imask...) */
279199767f8SToomas Soome 
280199767f8SToomas Soome typedef	__uintfptr_t	uintfptr_t;
281199767f8SToomas Soome typedef	__uint64_t	uoff_t;
282199767f8SToomas Soome typedef	char		vm_memattr_t;	/* memory attribute codes */
283199767f8SToomas Soome typedef	struct vm_page	*vm_page_t;
284199767f8SToomas Soome 
285199767f8SToomas Soome #if !defined(__bool_true_false_are_defined) && !defined(__cplusplus)
286199767f8SToomas Soome #define	__bool_true_false_are_defined	1
287199767f8SToomas Soome #define	false	0
288199767f8SToomas Soome #define	true	1
289199767f8SToomas Soome #if __STDC_VERSION__ < 199901L && __GNUC__ < 3 && !defined(__INTEL_COMPILER)
290199767f8SToomas Soome typedef	int	_Bool;
291199767f8SToomas Soome #endif
292199767f8SToomas Soome typedef	_Bool	bool;
293199767f8SToomas Soome #endif /* !__bool_true_false_are_defined && !__cplusplus */
294199767f8SToomas Soome 
295199767f8SToomas Soome #define offsetof(type, field) __offsetof(type, field)
296199767f8SToomas Soome 
297*9890ff83SToomas Soome #else
298*9890ff83SToomas Soome /* for illumos compatibility */
299*9890ff83SToomas Soome typedef enum boolean { B_FALSE, B_TRUE } boolean_t;
300*9890ff83SToomas Soome 
301199767f8SToomas Soome #endif /* !_KERNEL */
302199767f8SToomas Soome 
303199767f8SToomas Soome /*
304199767f8SToomas Soome  * The following are all things that really shouldn't exist in this header,
305199767f8SToomas Soome  * since its purpose is to provide typedefs, not miscellaneous doodads.
306199767f8SToomas Soome  */
307199767f8SToomas Soome 
308199767f8SToomas Soome #ifdef __POPCNT__
309199767f8SToomas Soome #define	__bitcount64(x)	__builtin_popcountll((__uint64_t)(x))
310199767f8SToomas Soome #define	__bitcount32(x)	__builtin_popcount((__uint32_t)(x))
311199767f8SToomas Soome #define	__bitcount16(x)	__builtin_popcount((__uint16_t)(x))
312199767f8SToomas Soome #define	__bitcountl(x)	__builtin_popcountl((unsigned long)(x))
313199767f8SToomas Soome #define	__bitcount(x)	__builtin_popcount((unsigned int)(x))
314199767f8SToomas Soome #else
315199767f8SToomas Soome /*
316199767f8SToomas Soome  * Population count algorithm using SWAR approach
317199767f8SToomas Soome  * - "SIMD Within A Register".
318199767f8SToomas Soome  */
319199767f8SToomas Soome static __inline __uint16_t
__bitcount16(__uint16_t _x)320199767f8SToomas Soome __bitcount16(__uint16_t _x)
321199767f8SToomas Soome {
322199767f8SToomas Soome 
323199767f8SToomas Soome 	_x = (_x & 0x5555) + ((_x & 0xaaaa) >> 1);
324199767f8SToomas Soome 	_x = (_x & 0x3333) + ((_x & 0xcccc) >> 2);
325199767f8SToomas Soome 	_x = (_x + (_x >> 4)) & 0x0f0f;
326199767f8SToomas Soome 	_x = (_x + (_x >> 8)) & 0x00ff;
327199767f8SToomas Soome 	return (_x);
328199767f8SToomas Soome }
329199767f8SToomas Soome 
330199767f8SToomas Soome static __inline __uint32_t
__bitcount32(__uint32_t _x)331199767f8SToomas Soome __bitcount32(__uint32_t _x)
332199767f8SToomas Soome {
333199767f8SToomas Soome 
334199767f8SToomas Soome 	_x = (_x & 0x55555555) + ((_x & 0xaaaaaaaa) >> 1);
335199767f8SToomas Soome 	_x = (_x & 0x33333333) + ((_x & 0xcccccccc) >> 2);
336199767f8SToomas Soome 	_x = (_x + (_x >> 4)) & 0x0f0f0f0f;
337199767f8SToomas Soome 	_x = (_x + (_x >> 8));
338199767f8SToomas Soome 	_x = (_x + (_x >> 16)) & 0x000000ff;
339199767f8SToomas Soome 	return (_x);
340199767f8SToomas Soome }
341199767f8SToomas Soome 
342199767f8SToomas Soome #ifdef __LP64__
343199767f8SToomas Soome static __inline __uint64_t
__bitcount64(__uint64_t _x)344199767f8SToomas Soome __bitcount64(__uint64_t _x)
345199767f8SToomas Soome {
346199767f8SToomas Soome 
347199767f8SToomas Soome 	_x = (_x & 0x5555555555555555) + ((_x & 0xaaaaaaaaaaaaaaaa) >> 1);
348199767f8SToomas Soome 	_x = (_x & 0x3333333333333333) + ((_x & 0xcccccccccccccccc) >> 2);
349199767f8SToomas Soome 	_x = (_x + (_x >> 4)) & 0x0f0f0f0f0f0f0f0f;
350199767f8SToomas Soome 	_x = (_x + (_x >> 8));
351199767f8SToomas Soome 	_x = (_x + (_x >> 16));
352199767f8SToomas Soome 	_x = (_x + (_x >> 32)) & 0x000000ff;
353199767f8SToomas Soome 	return (_x);
354199767f8SToomas Soome }
355199767f8SToomas Soome 
356199767f8SToomas Soome #define	__bitcountl(x)	__bitcount64((unsigned long)(x))
357199767f8SToomas Soome #else
358199767f8SToomas Soome static __inline __uint64_t
__bitcount64(__uint64_t _x)359199767f8SToomas Soome __bitcount64(__uint64_t _x)
360199767f8SToomas Soome {
361199767f8SToomas Soome 
362199767f8SToomas Soome 	return (__bitcount32(_x >> 32) + __bitcount32(_x));
363199767f8SToomas Soome }
364199767f8SToomas Soome 
365199767f8SToomas Soome #define	__bitcountl(x)	__bitcount32((unsigned long)(x))
366199767f8SToomas Soome #endif
367199767f8SToomas Soome #define	__bitcount(x)	__bitcount32((unsigned int)(x))
368199767f8SToomas Soome #endif
369199767f8SToomas Soome 
370199767f8SToomas Soome #if __BSD_VISIBLE
371199767f8SToomas Soome 
372199767f8SToomas Soome #include <sys/select.h>
373199767f8SToomas Soome 
374199767f8SToomas Soome /*
375199767f8SToomas Soome  * minor() gives a cookie instead of an index since we don't want to
376199767f8SToomas Soome  * change the meanings of bits 0-15 or waste time and space shifting
377199767f8SToomas Soome  * bits 16-31 for devices that don't use them.
378199767f8SToomas Soome  */
379199767f8SToomas Soome #define	major(x)	((int)(((u_int)(x) >> 8)&0xff))	/* major number */
380199767f8SToomas Soome #define	minor(x)	((int)((x)&0xffff00ff))		/* minor number */
381199767f8SToomas Soome #define	makedev(x,y)	((dev_t)(((x) << 8) | (y)))	/* create dev_t */
382199767f8SToomas Soome 
383199767f8SToomas Soome /*
384199767f8SToomas Soome  * These declarations belong elsewhere, but are repeated here and in
385199767f8SToomas Soome  * <stdio.h> to give broken programs a better chance of working with
386199767f8SToomas Soome  * 64-bit off_t's.
387199767f8SToomas Soome  */
388199767f8SToomas Soome #ifndef _KERNEL
389199767f8SToomas Soome __BEGIN_DECLS
390199767f8SToomas Soome #ifndef _FTRUNCATE_DECLARED
391199767f8SToomas Soome #define	_FTRUNCATE_DECLARED
392199767f8SToomas Soome int	 ftruncate(int, off_t);
393199767f8SToomas Soome #endif
394199767f8SToomas Soome #ifndef _LSEEK_DECLARED
395199767f8SToomas Soome #define	_LSEEK_DECLARED
396199767f8SToomas Soome off_t	 lseek(int, off_t, int);
397199767f8SToomas Soome #endif
398199767f8SToomas Soome #ifndef _MMAP_DECLARED
399199767f8SToomas Soome #define	_MMAP_DECLARED
400199767f8SToomas Soome void *	 mmap(void *, size_t, int, int, int, off_t);
401199767f8SToomas Soome #endif
402199767f8SToomas Soome #ifndef _TRUNCATE_DECLARED
403199767f8SToomas Soome #define	_TRUNCATE_DECLARED
404199767f8SToomas Soome int	 truncate(const char *, off_t);
405199767f8SToomas Soome #endif
406199767f8SToomas Soome __END_DECLS
407199767f8SToomas Soome #endif /* !_KERNEL */
408199767f8SToomas Soome 
409199767f8SToomas Soome #endif /* __BSD_VISIBLE */
410199767f8SToomas Soome 
411199767f8SToomas Soome #endif /* !_SYS_TYPES_H_ */
412