xref: /csrg-svn/sys/sys/types.h (revision 68365)
149219Sbostic /*-
267511Sbostic  * Copyright (c) 1982, 1986, 1991, 1993, 1994
361064Sbostic  *	The Regents of the University of California.  All rights reserved.
465772Sbostic  * (c) UNIX System Laboratories, Inc.
565772Sbostic  * All or some portions of this file are derived from material licensed
665772Sbostic  * to the University of California by American Telephone and Telegraph
765772Sbostic  * Co. or Unix System Laboratories, Inc. and are reproduced herein with
865772Sbostic  * the permission of UNIX System Laboratories, Inc.
923450Smckusick  *
1049219Sbostic  * %sccs.include.redist.c%
1149219Sbostic  *
12*68365Scgd  *	@(#)types.h	8.6 (Berkeley) 02/19/95
1323450Smckusick  */
143337Swnj 
1565420Sbostic #ifndef _SYS_TYPES_H_
1665420Sbostic #define	_SYS_TYPES_H_
173337Swnj 
1852011Smckusick /* Machine type dependent parameters. */
1967511Sbostic #include <machine/ansi.h>
2067511Sbostic #include <machine/types.h>
2152011Smckusick 
2257911Sbostic #ifndef _POSIX_SOURCE
233337Swnj typedef	unsigned char	u_char;
243337Swnj typedef	unsigned short	u_short;
253337Swnj typedef	unsigned int	u_int;
263337Swnj typedef	unsigned long	u_long;
2743871Sbostic typedef	unsigned short	ushort;		/* Sys V compatibility */
2859594Sbostic typedef	unsigned int	uint;		/* Sys V compatibility */
2957911Sbostic #endif
303337Swnj 
3167511Sbostic typedef	u_int64_t	u_quad_t;	/* quads */
3267511Sbostic typedef	int64_t		quad_t;
3357911Sbostic typedef	quad_t *	qaddr_t;
3449219Sbostic 
3557911Sbostic typedef	char *		caddr_t;	/* core address */
3667511Sbostic typedef	int32_t		daddr_t;	/* disk address */
3767511Sbostic typedef	u_int32_t	dev_t;		/* device number */
3867511Sbostic typedef u_int32_t	fixpt_t;	/* fixed point number */
3967511Sbostic typedef	u_int32_t	gid_t;		/* group id */
4067511Sbostic typedef	u_int32_t	ino_t;		/* inode number */
41*68365Scgd typedef	long		key_t;		/* IPC key (for Sys V IPC) */
4267511Sbostic typedef	u_int16_t	mode_t;		/* permissions */
4367511Sbostic typedef	u_int16_t	nlink_t;	/* link count */
4457911Sbostic typedef	quad_t		off_t;		/* file offset */
4567511Sbostic typedef	int32_t		pid_t;		/* process id */
4667511Sbostic typedef	int32_t		segsz_t;	/* segment size */
4767511Sbostic typedef	int32_t		swblk_t;	/* swap offset */
4867511Sbostic typedef	u_int32_t	uid_t;		/* user id */
4957911Sbostic 
5059654Smckusick /*
5159654Smckusick  * This belongs in unistd.h, but is placed here to ensure that programs
5259654Smckusick  * casting the second parameter of lseek to off_t will get the correct
5359654Smckusick  * version of lseek.
5459654Smckusick  */
5559654Smckusick #ifndef KERNEL
5665575Sbostic #include <sys/cdefs.h>
5759654Smckusick __BEGIN_DECLS
5859654Smckusick off_t	 lseek __P((int, off_t, int));
5959654Smckusick __END_DECLS
6059654Smckusick #endif
6159654Smckusick 
6249219Sbostic #ifndef _POSIX_SOURCE
6367511Sbostic 							/* major number */
6467511Sbostic #define	major(x)	((int32_t)(((u_int32_t)(x) >> 8) & 0xff))
6567511Sbostic #define	minor(x)	((int32_t)((x) & 0xff))		/* minor number */
6667511Sbostic #define	makedev(x,y)	((dev_t)(((x) << 8) | (y)))	/* create dev_t */
6749219Sbostic #endif
6849219Sbostic 
6967511Sbostic #include <machine/endian.h>
7043871Sbostic 
7154266Sbostic #ifdef	_BSD_CLOCK_T_
7254266Sbostic typedef	_BSD_CLOCK_T_	clock_t;
7354266Sbostic #undef	_BSD_CLOCK_T_
7443871Sbostic #endif
7543871Sbostic 
7654266Sbostic #ifdef	_BSD_SIZE_T_
7754266Sbostic typedef	_BSD_SIZE_T_	size_t;
7854266Sbostic #undef	_BSD_SIZE_T_
7947180Sbostic #endif
8047180Sbostic 
8154266Sbostic #ifdef	_BSD_SSIZE_T_
8254266Sbostic typedef	_BSD_SSIZE_T_	ssize_t;
8354266Sbostic #undef	_BSD_SSIZE_T_
8451840Sbostic #endif
8551840Sbostic 
8654266Sbostic #ifdef	_BSD_TIME_T_
8754266Sbostic typedef	_BSD_TIME_T_	time_t;
8854266Sbostic #undef	_BSD_TIME_T_
8943871Sbostic #endif
9043871Sbostic 
9143871Sbostic #ifndef _POSIX_SOURCE
9223752Skarels #define	NBBY	8		/* number of bits in a byte */
9342160Sbostic 
9423522Skarels /*
9542160Sbostic  * Select uses bit masks of file descriptors in longs.  These macros
9642160Sbostic  * manipulate such bit fields (the filesystem macros use chars).
9742160Sbostic  * FD_SETSIZE may be defined by the user, but the default here should
9849219Sbostic  * be enough for most uses.
9923522Skarels  */
10023522Skarels #ifndef	FD_SETSIZE
10123752Skarels #define	FD_SETSIZE	256
10216585Ssam #endif
10323522Skarels 
10467511Sbostic typedef int32_t	fd_mask;
10523522Skarels #define NFDBITS	(sizeof(fd_mask) * NBBY)	/* bits per mask */
10642160Sbostic 
10723752Skarels #ifndef howmany
10867511Sbostic #define	howmany(x, y)	(((x) + ((y) - 1)) / (y))
10923752Skarels #endif
11023522Skarels 
11123522Skarels typedef	struct fd_set {
11223522Skarels 	fd_mask	fds_bits[howmany(FD_SETSIZE, NFDBITS)];
11323522Skarels } fd_set;
11423522Skarels 
11523522Skarels #define	FD_SET(n, p)	((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))
11623522Skarels #define	FD_CLR(n, p)	((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
11723522Skarels #define	FD_ISSET(n, p)	((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
11855833Sbostic #define	FD_COPY(f, t)	bcopy(f, t, sizeof(*(f)))
11953462Smckusick #define	FD_ZERO(p)	bzero(p, sizeof(*(p)))
12023522Skarels 
12148390Skarels #if defined(__STDC__) && defined(KERNEL)
12248390Skarels /*
12359594Sbostic  * Forward structure declarations for function prototypes.  We include the
12459594Sbostic  * common structures that cross subsystem boundaries here; others are mostly
12559594Sbostic  * used in the same place that the structure is defined.
12648390Skarels  */
12748390Skarels struct	proc;
12848390Skarels struct	pgrp;
12948390Skarels struct	ucred;
13048390Skarels struct	rusage;
13148390Skarels struct	file;
13248390Skarels struct	buf;
13349091Skarels struct	tty;
13448390Skarels struct	uio;
13548390Skarels #endif
13648390Skarels 
13743871Sbostic #endif /* !_POSIX_SOURCE */
13865420Sbostic #endif /* !_SYS_TYPES_H_ */
139