xref: /original-bsd/sys/sys/types.h (revision a8f14c12)
1 /*-
2  * Copyright (c) 1982, 1986, 1991 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  *
7  *	@(#)types.h	7.17 (Berkeley) 05/06/91
8  */
9 
10 #ifndef _TYPES_H_
11 #define	_TYPES_H_
12 
13 typedef	unsigned char	u_char;
14 typedef	unsigned short	u_short;
15 typedef	unsigned int	u_int;
16 typedef	unsigned long	u_long;
17 typedef	unsigned short	ushort;		/* Sys V compatibility */
18 
19 typedef	char *	caddr_t;		/* core address */
20 typedef	long	daddr_t;		/* disk address */
21 typedef	short	dev_t;			/* device number */
22 typedef	u_long	ino_t;			/* inode number */
23 typedef	long	off_t;			/* file offset (should be a quad) */
24 typedef	u_short	nlink_t;		/* link count */
25 typedef	long	swblk_t;		/* swap offset */
26 typedef	long	segsz_t;		/* segment size */
27 typedef	u_short	uid_t;			/* user id */
28 typedef	u_short	gid_t;			/* group id */
29 typedef	short	pid_t;			/* process id */
30 typedef	u_short	mode_t;			/* permissions */
31 typedef u_long	fixpt_t;		/* fixed point number */
32 
33 #ifndef _POSIX_SOURCE
34 typedef	struct	_uquad	{ u_long val[2]; } u_quad;
35 typedef	struct	_quad	{   long val[2]; } quad;
36 typedef	long *	qaddr_t;	/* should be typedef quad * qaddr_t; */
37 
38 #define	major(x)	((int)(((u_int)(x) >> 8)&0xff))	/* major number */
39 #define	minor(x)	((int)((x)&0xff))		/* minor number */
40 #define	makedev(x,y)	((dev_t)(((x)<<8) | (y)))	/* create dev_t */
41 #endif
42 
43 #include <machine/ansi.h>
44 #if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
45 #include <machine/types.h>
46 #endif
47 
48 #ifdef	_CLOCK_T_
49 typedef	_CLOCK_T_	clock_t;
50 #undef	_CLOCK_T_
51 #endif
52 
53 #ifdef	_SIZE_T_
54 typedef	_SIZE_T_	size_t;
55 #undef	_SIZE_T_
56 #endif
57 
58 #ifdef	_TIME_T_
59 typedef	_TIME_T_	time_t;
60 #undef	_TIME_T_
61 #endif
62 
63 #ifndef _POSIX_SOURCE
64 #define	NBBY	8		/* number of bits in a byte */
65 
66 /*
67  * Select uses bit masks of file descriptors in longs.  These macros
68  * manipulate such bit fields (the filesystem macros use chars).
69  * FD_SETSIZE may be defined by the user, but the default here should
70  * be enough for most uses.
71  */
72 #ifndef	FD_SETSIZE
73 #define	FD_SETSIZE	256
74 #endif
75 
76 typedef long	fd_mask;
77 #define NFDBITS	(sizeof(fd_mask) * NBBY)	/* bits per mask */
78 
79 #ifndef howmany
80 #define	howmany(x, y)	(((x)+((y)-1))/(y))
81 #endif
82 
83 typedef	struct fd_set {
84 	fd_mask	fds_bits[howmany(FD_SETSIZE, NFDBITS)];
85 } fd_set;
86 
87 #define	FD_SET(n, p)	((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))
88 #define	FD_CLR(n, p)	((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
89 #define	FD_ISSET(n, p)	((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
90 #define	FD_ZERO(p)	bzero((char *)(p), sizeof(*(p)))
91 
92 #if defined(__STDC__) && defined(KERNEL)
93 /*
94  * Forward structure declarations for function prototypes.
95  * We include the common structures that cross subsystem boundaries here;
96  * others are mostly used in the same place that the structure is defined.
97  */
98 struct	proc;
99 struct	pgrp;
100 struct	ucred;
101 struct	rusage;
102 struct	file;
103 struct	buf;
104 struct	tty;
105 struct	uio;
106 #endif
107 
108 #endif /* !_POSIX_SOURCE */
109 #endif /* !_TYPES_H_ */
110