types.h revision 24896
11541Srgrimes/*-
214500Shsu * Copyright (c) 1982, 1986, 1991, 1993, 1994
31541Srgrimes *	The Regents of the University of California.  All rights reserved.
41541Srgrimes * (c) UNIX System Laboratories, Inc.
51541Srgrimes * All or some portions of this file are derived from material licensed
61541Srgrimes * to the University of California by American Telephone and Telegraph
71541Srgrimes * Co. or Unix System Laboratories, Inc. and are reproduced herein with
81541Srgrimes * the permission of UNIX System Laboratories, Inc.
91541Srgrimes *
101541Srgrimes * Redistribution and use in source and binary forms, with or without
111541Srgrimes * modification, are permitted provided that the following conditions
121541Srgrimes * are met:
131541Srgrimes * 1. Redistributions of source code must retain the above copyright
141541Srgrimes *    notice, this list of conditions and the following disclaimer.
151541Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
161541Srgrimes *    notice, this list of conditions and the following disclaimer in the
171541Srgrimes *    documentation and/or other materials provided with the distribution.
181541Srgrimes * 3. All advertising materials mentioning features or use of this software
191541Srgrimes *    must display the following acknowledgement:
201541Srgrimes *	This product includes software developed by the University of
211541Srgrimes *	California, Berkeley and its contributors.
221541Srgrimes * 4. Neither the name of the University nor the names of its contributors
231541Srgrimes *    may be used to endorse or promote products derived from this software
241541Srgrimes *    without specific prior written permission.
251541Srgrimes *
261541Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
271541Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
281541Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
291541Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
301541Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
311541Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
321541Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
331541Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
341541Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
351541Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
361541Srgrimes * SUCH DAMAGE.
371541Srgrimes *
3814500Shsu *	@(#)types.h	8.6 (Berkeley) 2/19/95
3924896Sbde * $Id: types.h,v 1.19 1997/04/13 15:27:12 bde Exp $
401541Srgrimes */
411541Srgrimes
421541Srgrimes#ifndef _SYS_TYPES_H_
431541Srgrimes#define	_SYS_TYPES_H_
441541Srgrimes
451541Srgrimes/* Machine type dependent parameters. */
4624895Sbde#include <sys/cdefs.h>			/* XXX for __signed in machine/ansi.h */
4714500Shsu#include <machine/ansi.h>
4814500Shsu#include <machine/types.h>
491541Srgrimes
501541Srgrimes#ifndef _POSIX_SOURCE
511541Srgrimestypedef	unsigned char	u_char;
521541Srgrimestypedef	unsigned short	u_short;
531541Srgrimestypedef	unsigned int	u_int;
541541Srgrimestypedef	unsigned long	u_long;
551541Srgrimestypedef	unsigned short	ushort;		/* Sys V compatibility */
561541Srgrimestypedef	unsigned int	uint;		/* Sys V compatibility */
571541Srgrimes#endif
581541Srgrimes
5914500Shsutypedef	u_int64_t	u_quad_t;	/* quads */
6014500Shsutypedef	int64_t		quad_t;
611541Srgrimestypedef	quad_t *	qaddr_t;
621541Srgrimes
631541Srgrimestypedef	char *		caddr_t;	/* core address */
6414500Shsutypedef	int32_t		daddr_t;	/* disk address */
6514500Shsutypedef	u_int32_t	dev_t;		/* device number */
6624895Sbdetypedef	u_int32_t	fixpt_t;	/* fixed point number */
6714500Shsutypedef	u_int32_t	gid_t;		/* group id */
6814500Shsutypedef	u_int32_t	ino_t;		/* inode number */
6914500Shsutypedef	long		key_t;		/* IPC key (for Sys V IPC) */
7014500Shsutypedef	u_int16_t	mode_t;		/* permissions */
7114500Shsutypedef	u_int16_t	nlink_t;	/* link count */
729342Sbdetypedef	_BSD_OFF_T_	off_t;		/* file offset */
739342Sbdetypedef	_BSD_PID_T_	pid_t;		/* process id */
7424895Sbdetypedef	quad_t		rlim_t;		/* resource limit */
7514500Shsutypedef	int32_t		segsz_t;	/* segment size */
7614500Shsutypedef	int32_t		swblk_t;	/* swap offset */
7714500Shsutypedef	u_int32_t	uid_t;		/* user id */
781541Srgrimes
7912642Sbde#ifdef KERNEL
8015481Sbdetypedef	int		boolean_t;
8115481Sbdetypedef	struct vm_page	*vm_page_t;
8212642Sbde#endif
8312642Sbde
841541Srgrimes#ifndef _POSIX_SOURCE
853093Sdg/*
863093Sdg * minor() gives a cookie instead of an index since we don't want to
873093Sdg * change the meanings of bits 0-15 or waste time and space shifting
883093Sdg * bits 16-31 for devices that don't use them.
893093Sdg */
901541Srgrimes#define	major(x)	((int)(((u_int)(x) >> 8)&0xff))	/* major number */
913093Sdg#define	minor(x)	((int)((x)&0xffff00ff))		/* minor number */
9214500Shsu#define	makedev(x,y)	((dev_t)(((x) << 8) | (y)))	/* create dev_t */
931541Srgrimes#endif
941541Srgrimes
9514500Shsu#include <machine/endian.h>
961541Srgrimes
971541Srgrimes#ifdef	_BSD_CLOCK_T_
981541Srgrimestypedef	_BSD_CLOCK_T_	clock_t;
991541Srgrimes#undef	_BSD_CLOCK_T_
1001541Srgrimes#endif
1011541Srgrimes
1021541Srgrimes#ifdef	_BSD_SIZE_T_
1031541Srgrimestypedef	_BSD_SIZE_T_	size_t;
1041541Srgrimes#undef	_BSD_SIZE_T_
1051541Srgrimes#endif
1061541Srgrimes
1071541Srgrimes#ifdef	_BSD_SSIZE_T_
1081541Srgrimestypedef	_BSD_SSIZE_T_	ssize_t;
1091541Srgrimes#undef	_BSD_SSIZE_T_
1101541Srgrimes#endif
1111541Srgrimes
1121541Srgrimes#ifdef	_BSD_TIME_T_
1131541Srgrimestypedef	_BSD_TIME_T_	time_t;
1141541Srgrimes#undef	_BSD_TIME_T_
1151541Srgrimes#endif
1161541Srgrimes
1171541Srgrimes#ifndef _POSIX_SOURCE
1181541Srgrimes#define	NBBY	8		/* number of bits in a byte */
1191541Srgrimes
1201541Srgrimes/*
1211541Srgrimes * Select uses bit masks of file descriptors in longs.  These macros
1221541Srgrimes * manipulate such bit fields (the filesystem macros use chars).
1231541Srgrimes * FD_SETSIZE may be defined by the user, but the default here should
1241541Srgrimes * be enough for most uses.
1251541Srgrimes */
1261541Srgrimes#ifndef	FD_SETSIZE
12722968Sache#define	FD_SETSIZE	1024
1281541Srgrimes#endif
1291541Srgrimes
13024895Sbdetypedef	long	fd_mask;
13124895Sbde#define	NFDBITS	(sizeof(fd_mask) * NBBY)	/* bits per mask */
1321541Srgrimes
1331541Srgrimes#ifndef howmany
13414500Shsu#define	howmany(x, y)	(((x) + ((y) - 1)) / (y))
1351541Srgrimes#endif
1361541Srgrimes
1371541Srgrimestypedef	struct fd_set {
1381541Srgrimes	fd_mask	fds_bits[howmany(FD_SETSIZE, NFDBITS)];
1391541Srgrimes} fd_set;
1401541Srgrimes
1411541Srgrimes#define	FD_SET(n, p)	((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))
1421541Srgrimes#define	FD_CLR(n, p)	((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
1431541Srgrimes#define	FD_ISSET(n, p)	((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
1441541Srgrimes#define	FD_COPY(f, t)	bcopy(f, t, sizeof(*(f)))
1451541Srgrimes#define	FD_ZERO(p)	bzero(p, sizeof(*(p)))
1461541Srgrimes
14724896Sbde/*
14824896Sbde * These declarations belong elsewhere, but are repeated here and in
14924896Sbde * <stdio.h> to give broken programs a better chance of working with
15024896Sbde * 64-bit off_t's.
15124896Sbde */
15224896Sbde#ifndef KERNEL
15324896Sbde#include <sys/cdefs.h>
15424896Sbde__BEGIN_DECLS
15524896Sbde#ifndef _FTRUNCATE_DECLARED
15624896Sbde#define	_FTRUNCATE_DECLARED
15724896Sbdeint	 ftruncate __P((int, off_t));
15824896Sbde#endif
15924896Sbde#ifndef _LSEEK_DECLARED
16024896Sbde#define	_LSEEK_DECLARED
16124896Sbdeoff_t	 lseek __P((int, off_t, int));
16224896Sbde#endif
16324896Sbde#ifndef _MMAP_DECLARED
16424896Sbde#define	_MMAP_DECLARED
16524896Sbdecaddr_t	 mmap __P((caddr_t, size_t, int, int, int, off_t));
16624896Sbde#endif
16724896Sbde#ifndef _TRUNCATE_DECLARED
16824896Sbde#define	_TRUNCATE_DECLARED
16924896Sbdeint	 truncate __P((const char *, off_t));
17024896Sbde#endif
17124896Sbde__END_DECLS
17224896Sbde#endif /* !KERNEL */
17324896Sbde
1741541Srgrimes#if defined(__STDC__) && defined(KERNEL)
1751541Srgrimes/*
1761541Srgrimes * Forward structure declarations for function prototypes.  We include the
1771541Srgrimes * common structures that cross subsystem boundaries here; others are mostly
1781541Srgrimes * used in the same place that the structure is defined.
1791541Srgrimes */
1801541Srgrimesstruct	proc;
1811541Srgrimesstruct	pgrp;
1821541Srgrimesstruct	ucred;
1831541Srgrimesstruct	rusage;
1841541Srgrimesstruct	file;
1851541Srgrimesstruct	buf;
1861541Srgrimesstruct	tty;
1871541Srgrimesstruct	uio;
1881541Srgrimes#endif
1891541Srgrimes
1901541Srgrimes#endif /* !_POSIX_SOURCE */
1911541Srgrimes#endif /* !_SYS_TYPES_H_ */
192