xref: /original-bsd/share/man/man5/types.5 (revision 0842ddeb)
1.\" Copyright (c) 1980, 1991, 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" %sccs.include.redist.roff%
5.\"
6.\"     @(#)types.5	8.2 (Berkeley) 04/28/95
7.\"
8.Dd
9.Dt TYPES 5
10.Os BSD 4
11.Sh NAME
12.Nm types
13.Nd system data types
14.Sh SYNOPSIS
15.Fd #include <sys/types.h>
16.Sh DESCRIPTION
17The file
18.Pa sys/types.h
19contains the defined data types used in the kernel (most are
20used through out the system).
21.Bd -literal
22#ifndef _SYS_TYPES_H_
23#define	_SYS_TYPES_H_
24
25/* Machine type dependent parameters. */
26#include <machine/ansi.h>
27#include <machine/types.h>
28
29#ifndef _POSIX_SOURCE
30typedef	unsigned char	u_char;
31typedef	unsigned short	u_short;
32typedef	unsigned int	u_int;
33typedef	unsigned long	u_long;
34typedef	unsigned short	ushort;		/* Sys V compatibility */
35typedef	unsigned int	uint;		/* Sys V compatibility */
36#endif
37
38typedef	u_int64_t	u_quad_t;	/* quads */
39typedef	int64_t		quad_t;
40typedef	quad_t *	qaddr_t;
41
42typedef	char *		caddr_t;	/* core address */
43typedef	int32_t		daddr_t;	/* disk address */
44typedef	u_int32_t	dev_t;		/* device number */
45typedef u_int32_t	fixpt_t;	/* fixed point number */
46typedef	u_int32_t	gid_t;		/* group id */
47typedef	u_int32_t	ino_t;		/* inode number */
48typedef	long		key_t;		/* IPC key (for Sys V IPC) */
49typedef	u_int16_t	mode_t;		/* permissions */
50typedef	u_int16_t	nlink_t;	/* link count */
51typedef	quad_t		off_t;		/* file offset */
52typedef	int32_t		pid_t;		/* process id */
53typedef	int32_t		segsz_t;	/* segment size */
54typedef	int32_t		swblk_t;	/* swap offset */
55typedef	u_int32_t	uid_t;		/* user id */
56
57/*
58 * This belongs in unistd.h, but is placed here to ensure that programs
59 * casting the second parameter of lseek to off_t will get the correct
60 * version of lseek.
61 */
62#ifndef KERNEL
63#include <sys/cdefs.h>
64__BEGIN_DECLS
65off_t	 lseek __P((int, off_t, int));
66__END_DECLS
67#endif
68
69#ifndef _POSIX_SOURCE
70							/* major number */
71#define	major(x)	((int32_t)(((u_int32_t)(x) >> 8) & 0xff))
72#define	minor(x)	((int32_t)((x) & 0xff))		/* minor number */
73#define	makedev(x,y)	((dev_t)(((x) << 8) | (y)))	/* create dev_t */
74#endif
75
76#include <machine/endian.h>
77
78#ifdef	_BSD_CLOCK_T_
79typedef	_BSD_CLOCK_T_	clock_t;
80#undef	_BSD_CLOCK_T_
81#endif
82
83#ifdef	_BSD_SIZE_T_
84typedef	_BSD_SIZE_T_	size_t;
85#undef	_BSD_SIZE_T_
86#endif
87
88#ifdef	_BSD_SSIZE_T_
89typedef	_BSD_SSIZE_T_	ssize_t;
90#undef	_BSD_SSIZE_T_
91#endif
92
93#ifdef	_BSD_TIME_T_
94typedef	_BSD_TIME_T_	time_t;
95#undef	_BSD_TIME_T_
96#endif
97
98#ifndef _POSIX_SOURCE
99#define	NBBY	8		/* number of bits in a byte */
100
101/*
102 * Select uses bit masks of file descriptors in longs.  These macros
103 * manipulate such bit fields (the filesystem macros use chars).
104 * FD_SETSIZE may be defined by the user, but the default here should
105 * be enough for most uses.
106 */
107#ifndef	FD_SETSIZE
108#define	FD_SETSIZE	256
109#endif
110
111typedef int32_t	fd_mask;
112#define NFDBITS	(sizeof(fd_mask) * NBBY)	/* bits per mask */
113
114#ifndef howmany
115#define	howmany(x, y)	(((x) + ((y) - 1)) / (y))
116#endif
117
118typedef	struct fd_set {
119	fd_mask	fds_bits[howmany(FD_SETSIZE, NFDBITS)];
120} fd_set;
121
122#define	FD_SET(n, p)	((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))
123#define	FD_CLR(n, p)	((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
124#define	FD_ISSET(n, p)	((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
125#define	FD_COPY(f, t)	bcopy(f, t, sizeof(*(f)))
126#define	FD_ZERO(p)	bzero(p, sizeof(*(p)))
127
128#if defined(__STDC__) && defined(KERNEL)
129/*
130 * Forward structure declarations for function prototypes.  We include the
131 * common structures that cross subsystem boundaries here; others are mostly
132 * used in the same place that the structure is defined.
133 */
134struct	proc;
135struct	pgrp;
136struct	ucred;
137struct	rusage;
138struct	file;
139struct	buf;
140struct	tty;
141struct	uio;
142#endif
143
144#endif /* !_POSIX_SOURCE */
145#endif /* !_SYS_TYPES_H_ */
146.Ed
147.Sh SEE ALSO
148.Xr fs 5 ,
149.Xr time 3 ,
150.Xr lseek 2 ,
151.Sh HISTORY
152A
153.Nm
154file appeared in
155.At v7 .
156