types.h revision 1541
1/*-
2 * Copyright (c) 1982, 1986, 1991, 1993
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. All advertising materials mentioning features or use of this software
19 *    must display the following acknowledgement:
20 *	This product includes software developed by the University of
21 *	California, Berkeley and its contributors.
22 * 4. Neither the name of the University nor the names of its contributors
23 *    may be used to endorse or promote products derived from this software
24 *    without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * SUCH DAMAGE.
37 *
38 *	@(#)types.h	8.4 (Berkeley) 1/21/94
39 */
40
41#ifndef _SYS_TYPES_H_
42#define	_SYS_TYPES_H_
43
44/* Machine type dependent parameters. */
45#include <machine/endian.h>
46
47#ifndef _POSIX_SOURCE
48typedef	unsigned char	u_char;
49typedef	unsigned short	u_short;
50typedef	unsigned int	u_int;
51typedef	unsigned long	u_long;
52typedef	unsigned short	ushort;		/* Sys V compatibility */
53typedef	unsigned int	uint;		/* Sys V compatibility */
54#endif
55
56typedef	unsigned long long u_quad_t;	/* quads */
57typedef	long long	quad_t;
58typedef	quad_t *	qaddr_t;
59
60typedef	char *		caddr_t;	/* core address */
61typedef	long		daddr_t;	/* disk address */
62typedef	unsigned long	dev_t;		/* device number */
63typedef unsigned long	fixpt_t;	/* fixed point number */
64typedef	unsigned long	gid_t;		/* group id */
65typedef	unsigned long	ino_t;		/* inode number */
66typedef	unsigned short	mode_t;		/* permissions */
67typedef	unsigned short	nlink_t;	/* link count */
68typedef	quad_t		off_t;		/* file offset */
69typedef	long		pid_t;		/* process id */
70typedef	long		segsz_t;	/* segment size */
71typedef	long		swblk_t;	/* swap offset */
72typedef	unsigned long	uid_t;		/* user id */
73
74/*
75 * This belongs in unistd.h, but is placed here to ensure that programs
76 * casting the second parameter of lseek to off_t will get the correct
77 * version of lseek.
78 */
79#ifndef KERNEL
80#include <sys/cdefs.h>
81__BEGIN_DECLS
82off_t	 lseek __P((int, off_t, int));
83__END_DECLS
84#endif
85
86#ifndef _POSIX_SOURCE
87#define	major(x)	((int)(((u_int)(x) >> 8)&0xff))	/* major number */
88#define	minor(x)	((int)((x)&0xff))		/* minor number */
89#define	makedev(x,y)	((dev_t)(((x)<<8) | (y)))	/* create dev_t */
90#endif
91
92#include <machine/ansi.h>
93#include <machine/types.h>
94
95#ifdef	_BSD_CLOCK_T_
96typedef	_BSD_CLOCK_T_	clock_t;
97#undef	_BSD_CLOCK_T_
98#endif
99
100#ifdef	_BSD_SIZE_T_
101typedef	_BSD_SIZE_T_	size_t;
102#undef	_BSD_SIZE_T_
103#endif
104
105#ifdef	_BSD_SSIZE_T_
106typedef	_BSD_SSIZE_T_	ssize_t;
107#undef	_BSD_SSIZE_T_
108#endif
109
110#ifdef	_BSD_TIME_T_
111typedef	_BSD_TIME_T_	time_t;
112#undef	_BSD_TIME_T_
113#endif
114
115#ifndef _POSIX_SOURCE
116#define	NBBY	8		/* number of bits in a byte */
117
118/*
119 * Select uses bit masks of file descriptors in longs.  These macros
120 * manipulate such bit fields (the filesystem macros use chars).
121 * FD_SETSIZE may be defined by the user, but the default here should
122 * be enough for most uses.
123 */
124#ifndef	FD_SETSIZE
125#define	FD_SETSIZE	256
126#endif
127
128typedef long	fd_mask;
129#define NFDBITS	(sizeof(fd_mask) * NBBY)	/* bits per mask */
130
131#ifndef howmany
132#define	howmany(x, y)	(((x)+((y)-1))/(y))
133#endif
134
135typedef	struct fd_set {
136	fd_mask	fds_bits[howmany(FD_SETSIZE, NFDBITS)];
137} fd_set;
138
139#define	FD_SET(n, p)	((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))
140#define	FD_CLR(n, p)	((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
141#define	FD_ISSET(n, p)	((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
142#define	FD_COPY(f, t)	bcopy(f, t, sizeof(*(f)))
143#define	FD_ZERO(p)	bzero(p, sizeof(*(p)))
144
145#if defined(__STDC__) && defined(KERNEL)
146/*
147 * Forward structure declarations for function prototypes.  We include the
148 * common structures that cross subsystem boundaries here; others are mostly
149 * used in the same place that the structure is defined.
150 */
151struct	proc;
152struct	pgrp;
153struct	ucred;
154struct	rusage;
155struct	file;
156struct	buf;
157struct	tty;
158struct	uio;
159#endif
160
161#endif /* !_POSIX_SOURCE */
162#endif /* !_SYS_TYPES_H_ */
163