xref: /original-bsd/sys/sys/types.h (revision 333da485)
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  * %sccs.include.redist.c%
11  *
12  *	@(#)types.h	8.4 (Berkeley) 01/21/94
13  */
14 
15 #ifndef _SYS_TYPES_H_
16 #define	_SYS_TYPES_H_
17 
18 /* Machine type dependent parameters. */
19 #include <machine/endian.h>
20 
21 #ifndef _POSIX_SOURCE
22 typedef	unsigned char	u_char;
23 typedef	unsigned short	u_short;
24 typedef	unsigned int	u_int;
25 typedef	unsigned long	u_long;
26 typedef	unsigned short	ushort;		/* Sys V compatibility */
27 typedef	unsigned int	uint;		/* Sys V compatibility */
28 #endif
29 
30 typedef	unsigned long long u_quad_t;	/* quads */
31 typedef	long long	quad_t;
32 typedef	quad_t *	qaddr_t;
33 
34 typedef	char *		caddr_t;	/* core address */
35 typedef	long		daddr_t;	/* disk address */
36 typedef	unsigned long	dev_t;		/* device number */
37 typedef unsigned long	fixpt_t;	/* fixed point number */
38 typedef	unsigned long	gid_t;		/* group id */
39 typedef	unsigned long	ino_t;		/* inode number */
40 typedef	unsigned short	mode_t;		/* permissions */
41 typedef	unsigned short	nlink_t;	/* link count */
42 typedef	quad_t		off_t;		/* file offset */
43 typedef	long		pid_t;		/* process id */
44 typedef	long		segsz_t;	/* segment size */
45 typedef	long		swblk_t;	/* swap offset */
46 typedef	unsigned long	uid_t;		/* user id */
47 
48 /*
49  * This belongs in unistd.h, but is placed here to ensure that programs
50  * casting the second parameter of lseek to off_t will get the correct
51  * version of lseek.
52  */
53 #ifndef KERNEL
54 #include <sys/cdefs.h>
55 __BEGIN_DECLS
56 off_t	 lseek __P((int, off_t, int));
57 __END_DECLS
58 #endif
59 
60 #ifndef _POSIX_SOURCE
61 #define	major(x)	((int)(((u_int)(x) >> 8)&0xff))	/* major number */
62 #define	minor(x)	((int)((x)&0xff))		/* minor number */
63 #define	makedev(x,y)	((dev_t)(((x)<<8) | (y)))	/* create dev_t */
64 #endif
65 
66 #include <machine/ansi.h>
67 #include <machine/types.h>
68 
69 #ifdef	_BSD_CLOCK_T_
70 typedef	_BSD_CLOCK_T_	clock_t;
71 #undef	_BSD_CLOCK_T_
72 #endif
73 
74 #ifdef	_BSD_SIZE_T_
75 typedef	_BSD_SIZE_T_	size_t;
76 #undef	_BSD_SIZE_T_
77 #endif
78 
79 #ifdef	_BSD_SSIZE_T_
80 typedef	_BSD_SSIZE_T_	ssize_t;
81 #undef	_BSD_SSIZE_T_
82 #endif
83 
84 #ifdef	_BSD_TIME_T_
85 typedef	_BSD_TIME_T_	time_t;
86 #undef	_BSD_TIME_T_
87 #endif
88 
89 #ifndef _POSIX_SOURCE
90 #define	NBBY	8		/* number of bits in a byte */
91 
92 /*
93  * Select uses bit masks of file descriptors in longs.  These macros
94  * manipulate such bit fields (the filesystem macros use chars).
95  * FD_SETSIZE may be defined by the user, but the default here should
96  * be enough for most uses.
97  */
98 #ifndef	FD_SETSIZE
99 #define	FD_SETSIZE	256
100 #endif
101 
102 typedef long	fd_mask;
103 #define NFDBITS	(sizeof(fd_mask) * NBBY)	/* bits per mask */
104 
105 #ifndef howmany
106 #define	howmany(x, y)	(((x)+((y)-1))/(y))
107 #endif
108 
109 typedef	struct fd_set {
110 	fd_mask	fds_bits[howmany(FD_SETSIZE, NFDBITS)];
111 } fd_set;
112 
113 #define	FD_SET(n, p)	((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))
114 #define	FD_CLR(n, p)	((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
115 #define	FD_ISSET(n, p)	((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
116 #define	FD_COPY(f, t)	bcopy(f, t, sizeof(*(f)))
117 #define	FD_ZERO(p)	bzero(p, sizeof(*(p)))
118 
119 #if defined(__STDC__) && defined(KERNEL)
120 /*
121  * Forward structure declarations for function prototypes.  We include the
122  * common structures that cross subsystem boundaries here; others are mostly
123  * used in the same place that the structure is defined.
124  */
125 struct	proc;
126 struct	pgrp;
127 struct	ucred;
128 struct	rusage;
129 struct	file;
130 struct	buf;
131 struct	tty;
132 struct	uio;
133 #endif
134 
135 #endif /* !_POSIX_SOURCE */
136 #endif /* !_SYS_TYPES_H_ */
137