xref: /original-bsd/share/man/man5/types.5 (revision c3e32dec)
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.1 (Berkeley) 06/05/93
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 _TYPES_H_
23#define	_TYPES_H_
24
25typedef	short	dev_t;
26#ifndef _POSIX_SOURCE
27					/* major part of a device */
28#define	major(x)	((int)(((unsigned)(x)>>8)&0377))
29					/* minor part of a device */
30#define	minor(x)	((int)((x)&0377))
31					/* make a device number */
32#define	makedev(x,y)	((dev_t)(((x)<<8) | (y)))
33#endif
34
35typedef	unsigned char	u_char;
36typedef	unsigned short	u_short;
37typedef	unsigned int	u_int;
38typedef	unsigned long	u_long;
39typedef	unsigned short	ushort;		/* Sys V compatibility */
40
41#include <machine/ansi.h>
42#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
43#include <machine/types.h>
44#endif
45
46#ifdef	_CLOCK_T_
47typedef	_CLOCK_T_	clock_t;
48#undef	_CLOCK_T_
49#endif
50
51#ifdef	_SIZE_T_
52typedef	_SIZE_T_	size_t;
53#undef	_SIZE_T_
54#endif
55
56#ifdef	_TIME_T_
57typedef	_TIME_T_	time_t;
58#undef	_TIME_T_
59#endif
60
61#ifndef _POSIX_SOURCE
62typedef	struct	_uquad { unsigned long val[2]; } u_quad;
63typedef	struct	_quad { long val[2]; } quad;
64#endif
65typedef	long *	qaddr_t;	/* should be typedef quad * qaddr_t; */
66
67typedef	long	daddr_t;
68typedef	char *	caddr_t;
69typedef	u_long	ino_t;
70typedef	long	swblk_t;
71typedef	long	segsz_t;
72typedef	long	off_t;
73typedef	u_short	uid_t;
74typedef	u_short	gid_t;
75typedef	short	pid_t;
76typedef	u_short	nlink_t;
77typedef	u_short	mode_t;
78typedef u_long	fixpt_t;
79
80#ifndef _POSIX_SOURCE
81#define	NBBY	8		/* number of bits in a byte */
82
83/*
84 * Select uses bit masks of file descriptors in longs.  These macros
85 * manipulate such bit fields (the filesystem macros use chars).
86 * FD_SETSIZE may be defined by the user, but the default here should
87 * be >= NOFILE (param.h).
88 */
89#ifndef	FD_SETSIZE
90#define	FD_SETSIZE	256
91#endif
92
93typedef long	fd_mask;
94#define NFDBITS	(sizeof(fd_mask) * NBBY)	/* bits per mask */
95
96#ifndef howmany
97#define	howmany(x, y)	(((x)+((y)-1))/(y))
98#endif
99
100typedef	struct fd_set {
101	fd_mask	fds_bits[howmany(FD_SETSIZE, NFDBITS)];
102} fd_set;
103
104#define	FD_SET(n, p)	((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))
105#define	FD_CLR(n, p)	((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
106#define	FD_ISSET(n, p)	((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
107#define	FD_ZERO(p)	bzero((char *)(p), sizeof(*(p)))
108
109#endif /* !_POSIX_SOURCE */
110#endif /* !_TYPES_H_ */
111.Ed
112.Sh SEE ALSO
113.Xr fs 5 ,
114.Xr time 3 ,
115.Xr lseek 2 ,
116.Xr adb 1
117.Sh HISTORY
118A
119.Nm
120file appeared in
121.At v7 .
122