Initial import from FreeBSD RELENG_4:
[dragonfly.git] / share / man / man5 / types.5
1 .\" Copyright (c) 1980, 1991, 1993
2 .\"     The Regents of the University of California.  All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\"    notice, this list of conditions and the following disclaimer in the
11 .\"    documentation and/or other materials provided with the distribution.
12 .\" 3. All advertising materials mentioning features or use of this software
13 .\"    must display the following acknowledgement:
14 .\"     This product includes software developed by the University of
15 .\"     California, Berkeley and its contributors.
16 .\" 4. Neither the name of the University nor the names of its contributors
17 .\"    may be used to endorse or promote products derived from this software
18 .\"    without specific prior written permission.
19 .\"
20 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 .\" SUCH DAMAGE.
31 .\"
32 .\"     @(#)types.5     8.1 (Berkeley) 6/5/93
33 .\" $FreeBSD: src/share/man/man5/types.5,v 1.10.2.2 2001/12/17 11:30:15 ru Exp $
34 .\"
35 .Dd June 5, 1993
36 .Dt TYPES 5
37 .Os
38 .Sh NAME
39 .Nm types
40 .Nd system data types
41 .Sh SYNOPSIS
42 .In sys/types.h
43 .Sh DESCRIPTION
44 The file
45 .Pa sys/types.h
46 contains the defined data types used in the kernel (most are
47 used through out the system).
48 .Bd -literal
49 #ifndef _SYS_TYPES_H_
50 #define _SYS_TYPES_H_
51
52 #include <sys/cdefs.h>
53
54 /* Machine type dependent parameters. */
55 #include <sys/inttypes.h>               /* includes <machine/ansi.h> */
56 #include <machine/types.h>
57
58 #ifndef _POSIX_SOURCE
59 typedef unsigned char   u_char;
60 typedef unsigned short  u_short;
61 typedef unsigned int    u_int;
62 typedef unsigned long   u_long;
63 typedef unsigned short  ushort;         /* Sys V compatibility */
64 typedef unsigned int    uint;           /* Sys V compatibility */
65 #endif
66
67 typedef __uint8_t       u_int8_t;
68 typedef __uint16_t      u_int16_t;
69 typedef __uint32_t      u_int32_t;
70 typedef __uint64_t      u_int64_t;
71
72 typedef u_int64_t       u_quad_t;       /* quads */
73 typedef int64_t         quad_t;
74 typedef quad_t *        qaddr_t;
75
76 typedef char *          caddr_t;        /* core address */
77 typedef __const char *  c_caddr_t;      /* core address, pointer to const */
78 typedef __volatile char *v_caddr_t;     /* core address, pointer to volatile */
79 typedef int32_t         daddr_t;        /* disk address */
80 typedef u_int32_t       u_daddr_t;      /* unsigned disk address */
81 typedef u_int32_t       fixpt_t;        /* fixed point number */
82 typedef u_int32_t       gid_t;          /* group id */
83 typedef u_int32_t       ino_t;          /* inode number */
84 typedef long            key_t;          /* IPC key (for Sys V IPC) */
85 typedef u_int16_t       mode_t;         /* permissions */
86 typedef u_int16_t       nlink_t;        /* link count */
87 typedef _BSD_OFF_T_     off_t;          /* file offset */
88 typedef _BSD_PID_T_     pid_t;          /* process id */
89 typedef quad_t          rlim_t;         /* resource limit */
90 #ifdef __alpha__                /* XXX should be in <machine/types.h> */
91 typedef int64_t         segsz_t;        /* segment size */
92 #else
93 typedef int32_t         segsz_t;        /* segment size */
94 #endif
95 typedef int32_t         swblk_t;        /* swap offset */
96 typedef int32_t         ufs_daddr_t;
97 typedef u_int32_t       uid_t;          /* user id */
98
99 #ifdef _KERNEL
100 typedef int             boolean_t;
101 typedef u_int64_t       uoff_t;
102 typedef struct vm_page  *vm_page_t;
103 #endif
104
105 #ifdef _KERNEL
106
107 struct specinfo;
108
109 typedef u_int32_t       udev_t;         /* device number */
110 typedef struct specinfo *dev_t;
111
112 #else /* !_KERNEL */
113
114 typedef u_int32_t       dev_t;          /* device number */
115 #define udev_t dev_t
116
117 #ifndef _POSIX_SOURCE
118
119 /*
120  * minor() gives a cookie instead of an index since we don't want to
121  * change the meanings of bits 0-15 or waste time and space shifting
122  * bits 16-31 for devices that don't use them.
123  */
124 #define major(x)        ((int)(((u_int)(x) >> 8)&0xff)) /* major number */
125 #define minor(x)        ((int)((x)&0xffff00ff))         /* minor number */
126 #define makedev(x,y)    ((dev_t)(((x) << 8) | (y)))     /* create dev_t */
127
128 #endif /* _POSIX_SOURCE */
129
130 #endif /* !_KERNEL */
131
132 #include <machine/endian.h>
133
134 #ifdef  _BSD_CLOCK_T_
135 typedef _BSD_CLOCK_T_   clock_t;
136 #undef  _BSD_CLOCK_T_
137 #endif
138
139 #ifdef  _BSD_CLOCKID_T_
140 typedef _BSD_CLOCKID_T_ clockid_t;
141 #undef  _BSD_CLOCKID_T_
142 #endif
143
144 #ifdef  _BSD_SIZE_T_
145 typedef _BSD_SIZE_T_    size_t;
146 #undef  _BSD_SIZE_T_
147 #endif
148
149 #ifdef  _BSD_SSIZE_T_
150 typedef _BSD_SSIZE_T_   ssize_t;
151 #undef  _BSD_SSIZE_T_
152 #endif
153
154 #ifdef  _BSD_TIME_T_
155 typedef _BSD_TIME_T_    time_t;
156 #undef  _BSD_TIME_T_
157 #endif
158
159 #ifdef  _BSD_TIMER_T_
160 typedef _BSD_TIMER_T_   timer_t;
161 #undef  _BSD_TIMER_T_
162 #endif
163
164 #ifndef _POSIX_SOURCE
165 #define NBBY    8               /* number of bits in a byte */
166
167 /*
168  * Select uses bit masks of file descriptors in longs.  These macros
169  * manipulate such bit fields (the filesystem macros use chars).
170  * FD_SETSIZE may be defined by the user, but the default here should
171  * be enough for most uses.
172  */
173 #ifndef FD_SETSIZE
174 #define FD_SETSIZE      1024
175 #endif
176
177 typedef long    fd_mask;
178 #define NFDBITS (sizeof(fd_mask) * NBBY)        /* bits per mask */
179
180 #ifndef howmany
181 #define howmany(x, y)   (((x) + ((y) - 1)) / (y))
182 #endif
183
184 typedef struct fd_set {
185         fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)];
186 } fd_set;
187
188 #define FD_SET(n, p)    ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))
189 #define FD_CLR(n, p)    ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
190 #define FD_ISSET(n, p)  ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
191 #define FD_COPY(f, t)   bcopy(f, t, sizeof(*(f)))
192 #define FD_ZERO(p)      bzero(p, sizeof(*(p)))
193
194 /*
195  * These declarations belong elsewhere, but are repeated here and in
196  * <stdio.h> to give broken programs a better chance of working with
197  * 64-bit off_t's.
198  */
199 #ifndef _KERNEL
200 __BEGIN_DECLS
201 #ifndef _FTRUNCATE_DECLARED
202 #define _FTRUNCATE_DECLARED
203 int      ftruncate __P((int, off_t));
204 #endif
205 #ifndef _LSEEK_DECLARED
206 #define _LSEEK_DECLARED
207 off_t    lseek __P((int, off_t, int));
208 #endif
209 #ifndef _MMAP_DECLARED
210 #define _MMAP_DECLARED
211 void *   mmap __P((void *, size_t, int, int, int, off_t));
212 #endif
213 #ifndef _TRUNCATE_DECLARED
214 #define _TRUNCATE_DECLARED
215 int      truncate __P((const char *, off_t));
216 #endif
217 __END_DECLS
218 #endif /* !_KERNEL */
219
220 #endif /* !_POSIX_SOURCE */
221
222 #endif /* !_SYS_TYPES_H_ */
223 .Ed
224 .Sh SEE ALSO
225 .Xr gdb 1 ,
226 .Xr lseek 2 ,
227 .Xr time 3 ,
228 .Xr fs 5
229 .Sh HISTORY
230 A
231 .Nm
232 file appeared in
233 .At v7 .