Mega mdoc(7) update:
[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 .\" $DragonFly: src/share/man/man5/Attic/types.5,v 1.5 2003/11/14 03:54:32 dillon Exp $
35 .\"
36 .Dd June 5, 1993
37 .Dt TYPES 5
38 .Os
39 .Sh NAME
40 .Nm types
41 .Nd system data types
42 .Sh SYNOPSIS
43 .In sys/types.h
44 .Sh DESCRIPTION
45 The file
46 .Pa sys/types.h
47 contains the defined data types used in the kernel (most are
48 used through out the system).
49 .Bd -literal
50 #ifndef _SYS_TYPES_H_
51 #define _SYS_TYPES_H_
52
53 #include <sys/cdefs.h>
54
55 /* Machine type dependent parameters. */
56 #include <sys/inttypes.h>
57 #include <machine/stdint.h>
58 #include <machine/types.h>
59
60 #ifndef _POSIX_SOURCE
61 typedef unsigned char   u_char;
62 typedef unsigned short  u_short;
63 typedef unsigned int    u_int;
64 typedef unsigned long   u_long;
65 typedef unsigned short  ushort;         /* Sys V compatibility */
66 typedef unsigned int    uint;           /* Sys V compatibility */
67 #endif
68
69 typedef __uint8_t       u_int8_t;
70 typedef __uint16_t      u_int16_t;
71 typedef __uint32_t      u_int32_t;
72 typedef __uint64_t      u_int64_t;
73
74 typedef u_int64_t       u_quad_t;       /* quads */
75 typedef int64_t         quad_t;
76 typedef quad_t *        qaddr_t;
77
78 typedef char *          caddr_t;        /* core address */
79 typedef const char *    c_caddr_t;      /* core address, pointer to const */
80 typedef volatile char *v_caddr_t;       /* core address, pointer to volatile */
81 typedef int32_t         daddr_t;        /* disk address */
82 typedef u_int32_t       u_daddr_t;      /* unsigned disk address */
83 typedef u_int32_t       fixpt_t;        /* fixed point number */
84 typedef u_int32_t       gid_t;          /* group id */
85 typedef u_int32_t       ino_t;          /* inode number */
86 typedef long            key_t;          /* IPC key (for Sys V IPC) */
87 typedef u_int16_t       mode_t;         /* permissions */
88 typedef u_int16_t       nlink_t;        /* link count */
89 typedef _BSD_OFF_T_     off_t;          /* file offset */
90 typedef _BSD_PID_T_     pid_t;          /* process id */
91 typedef quad_t          rlim_t;         /* resource limit */
92 #ifdef __alpha__                /* XXX should be in <machine/types.h> */
93 typedef int64_t         segsz_t;        /* segment size */
94 #else
95 typedef int32_t         segsz_t;        /* segment size */
96 #endif
97 typedef int32_t         swblk_t;        /* swap offset */
98 typedef int32_t         ufs_daddr_t;
99 typedef u_int32_t       uid_t;          /* user id */
100
101 #ifdef _KERNEL
102 typedef int             boolean_t;
103 typedef u_int64_t       uoff_t;
104 typedef struct vm_page  *vm_page_t;
105 #endif
106
107 #ifdef _KERNEL
108
109 struct specinfo;
110
111 typedef u_int32_t       udev_t;         /* device number */
112 typedef struct specinfo *dev_t;
113
114 #else /* !_KERNEL */
115
116 typedef u_int32_t       dev_t;          /* device number */
117 #define udev_t dev_t
118
119 #ifndef _POSIX_SOURCE
120
121 /*
122  * minor() gives a cookie instead of an index since we don't want to
123  * change the meanings of bits 0-15 or waste time and space shifting
124  * bits 16-31 for devices that don't use them.
125  */
126 #define major(x)        ((int)(((u_int)(x) >> 8)&0xff)) /* major number */
127 #define minor(x)        ((int)((x)&0xffff00ff))         /* minor number */
128 #define makedev(x,y)    ((dev_t)(((x) << 8) | (y)))     /* create dev_t */
129
130 #endif /* _POSIX_SOURCE */
131
132 #endif /* !_KERNEL */
133
134 #include <machine/endian.h>
135
136 #ifdef  _BSD_CLOCK_T_
137 typedef _BSD_CLOCK_T_   clock_t;
138 #undef  _BSD_CLOCK_T_
139 #endif
140
141 #ifdef  _BSD_CLOCKID_T_
142 typedef _BSD_CLOCKID_T_ clockid_t;
143 #undef  _BSD_CLOCKID_T_
144 #endif
145
146 #ifdef  _BSD_SIZE_T_
147 typedef _BSD_SIZE_T_    size_t;
148 #undef  _BSD_SIZE_T_
149 #endif
150
151 #ifdef  _BSD_SSIZE_T_
152 typedef _BSD_SSIZE_T_   ssize_t;
153 #undef  _BSD_SSIZE_T_
154 #endif
155
156 #ifdef  _BSD_TIME_T_
157 typedef _BSD_TIME_T_    time_t;
158 #undef  _BSD_TIME_T_
159 #endif
160
161 #ifdef  _BSD_TIMER_T_
162 typedef _BSD_TIMER_T_   timer_t;
163 #undef  _BSD_TIMER_T_
164 #endif
165
166 #ifndef _POSIX_SOURCE
167 #define NBBY    8               /* number of bits in a byte */
168
169 /*
170  * Select uses bit masks of file descriptors in longs.  These macros
171  * manipulate such bit fields (the filesystem macros use chars).
172  * FD_SETSIZE may be defined by the user, but the default here should
173  * be enough for most uses.
174  */
175 #ifndef FD_SETSIZE
176 #define FD_SETSIZE      1024
177 #endif
178
179 typedef long    fd_mask;
180 #define NFDBITS (sizeof(fd_mask) * NBBY)        /* bits per mask */
181
182 #ifndef howmany
183 #define howmany(x, y)   (((x) + ((y) - 1)) / (y))
184 #endif
185
186 typedef struct fd_set {
187         fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)];
188 } fd_set;
189
190 #define FD_SET(n, p)    ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))
191 #define FD_CLR(n, p)    ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
192 #define FD_ISSET(n, p)  ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
193 #define FD_COPY(f, t)   bcopy(f, t, sizeof(*(f)))
194 #define FD_ZERO(p)      bzero(p, sizeof(*(p)))
195
196 /*
197  * These declarations belong elsewhere, but are repeated here and in
198  * <stdio.h> to give broken programs a better chance of working with
199  * 64-bit off_t's.
200  */
201 #ifndef _KERNEL
202 __BEGIN_DECLS
203 #ifndef _FTRUNCATE_DECLARED
204 #define _FTRUNCATE_DECLARED
205 int      ftruncate (int, off_t);
206 #endif
207 #ifndef _LSEEK_DECLARED
208 #define _LSEEK_DECLARED
209 off_t    lseek (int, off_t, int);
210 #endif
211 #ifndef _MMAP_DECLARED
212 #define _MMAP_DECLARED
213 void *   mmap (void *, size_t, int, int, int, off_t);
214 #endif
215 #ifndef _TRUNCATE_DECLARED
216 #define _TRUNCATE_DECLARED
217 int      truncate (const char *, off_t);
218 #endif
219 __END_DECLS
220 #endif /* !_KERNEL */
221
222 #endif /* !_POSIX_SOURCE */
223
224 #endif /* !_SYS_TYPES_H_ */
225 .Ed
226 .Sh SEE ALSO
227 .Xr gdb 1 ,
228 .Xr lseek 2 ,
229 .Xr time 3 ,
230 .Xr fs 5
231 .Sh HISTORY
232 A
233 .Nm
234 file appeared in
235 .At v7 .