xref: /dragonfly/sys/sys/types.h (revision 7d3e9a5b)
1 /*-
2  * Copyright (c) 1982, 1986, 1991, 1993, 1994
3  *	The Regents of the University of California.  All rights reserved.
4  * (c) UNIX System Laboratories, Inc.
5  * All or some portions of this file are derived from material licensed
6  * to the University of California by American Telephone and Telegraph
7  * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8  * the permission of UNIX System Laboratories, Inc.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  * 3. Neither the name of the University nor the names of its contributors
19  *    may be used to endorse or promote products derived from this software
20  *    without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32  * SUCH DAMAGE.
33  *
34  *	@(#)types.h	8.6 (Berkeley) 2/19/95
35  * $FreeBSD: src/sys/sys/types.h,v 1.40.2.2 2001/04/21 14:53:06 ume Exp $
36  */
37 
38 #ifndef _SYS_TYPES_H_
39 #define	_SYS_TYPES_H_
40 
41 #ifndef _SYS_CDEFS_H_
42 #include <sys/cdefs.h>
43 #endif
44 #include <machine/endian.h>
45 #include <machine/stdint.h>
46 
47 #if __BSD_VISIBLE
48 typedef	unsigned char	u_char;
49 typedef	unsigned short	u_short;
50 typedef	unsigned int	u_int;
51 typedef	unsigned long	u_long;
52 
53 typedef	unsigned char	unchar;		/* Sys V compatibility */
54 typedef	unsigned short	ushort;		/* Sys V compatibility */
55 typedef	unsigned int	uint;		/* Sys V compatibility */
56 typedef	unsigned long	ulong;		/* Sys V compatibility */
57 #endif
58 
59 typedef	__uint8_t	u_int8_t;
60 typedef	__uint16_t	u_int16_t;
61 typedef	__uint32_t	u_int32_t;
62 typedef	__uint64_t	u_int64_t;
63 typedef	__uint64_t	u_quad_t;	/* quads */
64 typedef	__int64_t	quad_t;
65 typedef	quad_t *	qaddr_t;
66 
67 #ifndef _BLKCNT_T_DECLARED
68 typedef	__int64_t	blkcnt_t;	/* file block count */
69 #define	_BLKCNT_T_DECLARED
70 #endif
71 #ifndef _BLKSIZE_T_DECLARED
72 typedef	__int64_t	blksize_t;	/* block size */
73 #define	_BLKSIZE_T_DECLARED
74 #endif
75 typedef	char *		caddr_t;	/* core address */
76 typedef	const char *	c_caddr_t;	/* core address, pointer to const */
77 typedef	volatile char *	v_caddr_t;	/* core address, pointer to volatile */
78 typedef	__int32_t	daddr_t;	/* disk address */
79 typedef	__uint32_t	u_daddr_t;	/* unsigned disk address */
80 typedef	__uint32_t	fixpt_t;	/* fixed point number */
81 #ifndef _DEV_T_DECLARED
82 typedef	__uint32_t	dev_t;		/* device number */
83 #define	_DEV_T_DECLARED
84 #endif
85 #ifndef _FSBLKCNT_T_DECLARED
86 typedef	__uint64_t	fsblkcnt_t;	/* filesystem block count */
87 #define	_FSBLKCNT_T_DECLARED
88 #endif
89 #ifndef _FSFILCNT_T_DECLARED
90 typedef	__uint64_t	fsfilcnt_t;	/* filesystem file count */
91 #define	_FSFILCNT_T_DECLARED
92 #endif
93 #ifndef _GID_T_DECLARED
94 typedef	__uint32_t	gid_t;		/* group id */
95 #define	_GID_T_DECLARED
96 #endif
97 #ifndef _ID_T_DECLARED
98 typedef	__int64_t	id_t;		/* general id, can hold gid/pid/uid_t */
99 #define	_ID_T_DECLARED
100 #endif
101 #ifndef _IN_ADDR_T_DECLARED
102 typedef	__uint32_t	in_addr_t;	/* base type for internet address */
103 #define	_IN_ADDR_T_DECLARED
104 #endif
105 #ifndef _IN_PORT_T_DECLARED
106 typedef	__uint16_t	in_port_t;
107 #define	_IN_PORT_T_DECLARED
108 #endif
109 #ifndef _INO_T_DECLARED
110 typedef	__uint64_t	ino_t;		/* inode number */
111 #define	_INO_T_DECLARED
112 #endif
113 #ifndef _KEY_T_DECLARED
114 typedef	long		key_t;		/* IPC key (for Sys V IPC) */
115 #define	_KEY_T_DECLARED
116 #endif
117 #ifndef _MODE_T_DECLARED
118 typedef	__uint16_t	mode_t;		/* permissions */
119 #define	_MODE_T_DECLARED
120 #endif
121 #ifndef _NLINK_T_DECLARED
122 typedef	__uint32_t	nlink_t;	/* link count */
123 #define	_NLINK_T_DECLARED
124 #endif
125 #ifndef _OFF_T_DECLARED
126 typedef	__off_t		off_t;		/* file offset */
127 #define	_OFF_T_DECLARED
128 #endif
129 #ifndef _PID_T_DECLARED
130 typedef	__pid_t		pid_t;		/* process id */
131 #define	_PID_T_DECLARED
132 #endif
133 #if __BSD_VISIBLE
134 typedef	__register_t	register_t;	/* register-sized type */
135 #ifndef _RLIM_T_DECLARED
136 typedef	__rlim_t	rlim_t;		/* resource limit */
137 #define	_RLIM_T_DECLARED
138 #endif
139 typedef	__intlp_t	segsz_t;	/* segment size */
140 #endif
141 #ifndef _SUSECONDS_T_DECLARED
142 typedef	__suseconds_t	suseconds_t;	/* microseconds (signed) */
143 #define	_SUSECONDS_T_DECLARED
144 #endif
145 #ifndef _UID_T_DECLARED
146 typedef	__uint32_t	uid_t;		/* user id */
147 #define	_UID_T_DECLARED
148 #endif
149 #ifndef _USECONDS_T_DECLARED
150 typedef	__uint32_t	useconds_t;	/* microseconds (unsigned) */
151 #define	_USECONDS_T_DECLARED
152 #endif
153 
154 /*
155  * The kernel uses dev_t or cdev_t.  Userland uses dev_t.
156  * Virtual kernel builds needs dev_t in order to include userland headers.
157  */
158 #if defined(_KERNEL) || defined(_KERNEL_STRUCTURES)
159 struct cdev;
160 typedef	struct cdev	*cdev_t;
161 typedef	__uint64_t	uoff_t;		/* uio offset */
162 #endif /* _KERNEL || _KERNEL_STRUCTURES */
163 
164 #if __BSD_VISIBLE && !defined(_KERNEL)
165 /*
166  * minor() gives a cookie instead of an index since we don't want to
167  * change the meanings of bits 0-15 or waste time and space shifting
168  * bits 16-31 for devices that don't use them.
169  */
170 #define	major(x)	((int)(((u_int)(x) >> 8)&0xff)) /* major number */
171 #define	minor(x)	((int)((x)&0xffff00ff))         /* minor number */
172 #define	makedev(x,y)	((dev_t)(((x) << 8) | (y)))     /* create dev_t */
173 #endif /* __BSD_VISIBLE && !_KERNEL */
174 
175 #ifndef _CLOCK_T_DECLARED
176 #define	_CLOCK_T_DECLARED
177 typedef	__clock_t	clock_t;
178 #endif
179 
180 #ifndef _CLOCKID_T_DECLARED
181 #define	_CLOCKID_T_DECLARED
182 typedef	__clockid_t	clockid_t;
183 #endif
184 
185 #if __BSD_VISIBLE
186 #ifndef _LWPID_T_DECLARED
187 #define	_LWPID_T_DECLARED
188 typedef	__pid_t		lwpid_t;	/* light weight process id */
189 #endif
190 #endif
191 
192 #ifndef _SIZE_T_DECLARED
193 #define	_SIZE_T_DECLARED
194 typedef	__size_t	size_t;		/* _GCC_SIZE_T OK */
195 #endif
196 
197 #ifndef _SSIZE_T_DECLARED
198 #define	_SSIZE_T_DECLARED
199 typedef	__ssize_t	ssize_t;
200 #endif
201 
202 #ifndef _TIME_T_DECLARED
203 #define	_TIME_T_DECLARED
204 typedef	__time_t	time_t;
205 #endif
206 
207 #ifndef _TIMER_T_DECLARED
208 #define	_TIMER_T_DECLARED
209 typedef	__timer_t	timer_t;
210 #endif
211 
212 #ifndef _KERNEL
213 #ifndef _STDINT_H_
214 #include <stdint.h>			/* XXX */
215 #endif
216 #endif /* !_KERNEL */
217 
218 #if defined(_KERNEL) || defined(_KERNEL_STRUCTURES)
219 #ifndef _SYS_STDINT_H_
220 #include <sys/stdint.h>			/* kernel int types */
221 #endif
222 #include <machine/types.h>		/* for vm_offet_t */
223 #endif
224 
225 #if __BSD_VISIBLE
226 #include <sys/_fd_set.h>
227 #include <sys/_timeval.h>
228 #endif /* __BSD_VISIBLE */
229 
230 #if !defined(_KERNEL) && !defined(_STANDALONE)
231 #include <sys/_pthreadtypes.h>		/* now POSIX thread types */
232 #endif	/* !_KERNEL && !_STANDALONE */
233 
234 #endif /* !_SYS_TYPES_H_ */
235