386BSD 0.1 development
[unix-history] / usr / src / sys.386bsd / sys / types.h
CommitLineData
b688fc87
WJ
1/*-
2 * Copyright (c) 1982, 1986, 1991 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * @(#)types.h 7.17 (Berkeley) 5/6/91
34 */
35
36#ifndef _TYPES_H_
37#define _TYPES_H_
38
39typedef unsigned char u_char;
40typedef unsigned short u_short;
41typedef unsigned int u_int;
42typedef unsigned long u_long;
43typedef unsigned short ushort; /* Sys V compatibility */
44
45typedef char * caddr_t; /* core address */
46typedef long daddr_t; /* disk address */
47typedef short dev_t; /* device number */
48typedef u_long ino_t; /* inode number */
49typedef long off_t; /* file offset (should be a quad) */
50typedef u_short nlink_t; /* link count */
51typedef long swblk_t; /* swap offset */
52typedef long segsz_t; /* segment size */
53typedef u_short uid_t; /* user id */
54typedef u_short gid_t; /* group id */
55typedef short pid_t; /* process id */
56typedef u_short mode_t; /* permissions */
57typedef u_long fixpt_t; /* fixed point number */
58
59#ifndef _POSIX_SOURCE
60typedef struct _uquad { u_long val[2]; } u_quad;
61typedef struct _quad { long val[2]; } quad;
62typedef long * qaddr_t; /* should be typedef quad * qaddr_t; */
63
64#define major(x) ((int)(((u_int)(x) >> 8)&0xff)) /* major number */
65#define minor(x) ((int)((x)&0xff)) /* minor number */
66#define makedev(x,y) ((dev_t)(((x)<<8) | (y))) /* create dev_t */
67#endif
68
69#include <machine/ansi.h>
70#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
71#include <machine/types.h>
72#endif
73
74#ifdef _CLOCK_T_
75typedef _CLOCK_T_ clock_t;
76#undef _CLOCK_T_
77#endif
78
79#ifdef _SIZE_T_
80typedef _SIZE_T_ size_t;
81#undef _SIZE_T_
82#endif
83
84#ifdef _TIME_T_
85typedef _TIME_T_ time_t;
86#undef _TIME_T_
87#endif
88
89#ifndef _POSIX_SOURCE
90#define NBBY 8 /* number of bits in a byte */
91
92/*
93 * Select uses bit masks of file descriptors in longs. These macros
94 * manipulate such bit fields (the filesystem macros use chars).
95 * FD_SETSIZE may be defined by the user, but the default here should
96 * be enough for most uses.
97 */
98#ifndef FD_SETSIZE
99#define FD_SETSIZE 256
100#endif
101
102typedef long fd_mask;
103#define NFDBITS (sizeof(fd_mask) * NBBY) /* bits per mask */
104
105#ifndef howmany
106#define howmany(x, y) (((x)+((y)-1))/(y))
107#endif
108
109typedef struct fd_set {
110 fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)];
111} fd_set;
112
113#define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))
114#define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
115#define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
116#define FD_ZERO(p) bzero((char *)(p), sizeof(*(p)))
117
118#if defined(__STDC__) && defined(KERNEL)
119/*
120 * Forward structure declarations for function prototypes.
121 * We include the common structures that cross subsystem boundaries here;
122 * others are mostly used in the same place that the structure is defined.
123 */
124struct proc;
125struct pgrp;
126struct ucred;
127struct rusage;
128struct file;
129struct buf;
130struct tty;
131struct uio;
132#endif
133
134#endif /* !_POSIX_SOURCE */
135#endif /* !_TYPES_H_ */