xref: /netbsd-src/share/man/man3/types.3 (revision 946379e7b37692fc43f68eb0d1c10daa0a7f3b6c)
1.\"	$NetBSD: types.3,v 1.6 2011/04/10 10:02:34 jruoho Exp $
2.\"
3.\" Copyright (c) 2010 The NetBSD Foundation, Inc.
4.\" All rights reserved.
5.\"
6.\" This code is derived from software contributed to The NetBSD Foundation
7.\" by Jukka Ruohonen.
8.\"
9.\" Redistribution and use in source and binary forms, with or without
10.\" modification, are permitted provided that the following conditions
11.\" are met:
12.\" 1. Redistributions of source code must retain the above copyright
13.\"    notice, this list of conditions and the following disclaimer.
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\"    notice, this list of conditions and the following disclaimer in the
16.\"    documentation and/or other materials provided with the distribution.
17.\"
18.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28.\" POSSIBILITY OF SUCH DAMAGE.
29.\"
30.\" Copyright (c) 1980, 1991, 1993
31.\"	The Regents of the University of California.  All rights reserved.
32.\"
33.\" Redistribution and use in source and binary forms, with or without
34.\" modification, are permitted provided that the following conditions
35.\" are met:
36.\" 1. Redistributions of source code must retain the above copyright
37.\"    notice, this list of conditions and the following disclaimer.
38.\" 2. Redistributions in binary form must reproduce the above copyright
39.\"    notice, this list of conditions and the following disclaimer in the
40.\"    documentation and/or other materials provided with the distribution.
41.\" 3. Neither the name of the University nor the names of its contributors
42.\"    may be used to endorse or promote products derived from this software
43.\"    without specific prior written permission.
44.\"
45.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
46.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
47.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
48.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
49.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
50.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
51.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
52.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
53.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
54.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
55.\" SUCH DAMAGE.
56.\"
57.\"     @(#)types.5	8.1 (Berkeley) 6/5/93
58.\"
59.Dd April 10, 2011
60.Dt TYPES 3
61.Os
62.Sh NAME
63.Nm types
64.Nd standard system data types
65.Sh SYNOPSIS
66.In sys/types.h
67.Sh DESCRIPTION
68The
69.In sys/types.h
70header contains the common data types used in the system.
71Although these are meant to be used within the kernel,
72most of the system data types are accessible also to user code.
73A companion header
74.In sys/param.h ,
75typically used in the kernel,
76includes
77.In sys/types.h
78and provides additional types as well as other facilities (see
79.Xr param 3 ) .
80.Ss Standard Types
81The following standards-compliant system data types are defined:
82.Pp
83.Bl -column -offset indent \
84"suseconds_t " "process and process group IDs " "clock_settime(3) "
85.It Sy Type Ta Sy Typical use Ta Sy Example
86.It Va blkcnt_t Ta file block counts Ta Xr stat 2
87.It Va blksize_t Ta block sizes Ta Xr stat 2
88.It Va clock_t Ta system clock ticks Ta Xr clock 3
89.It Va clockid_t Ta clock IDs Ta Xr clock_settime 2
90.It Va dev_t Ta device IDs Ta Xr devname 3
91.It Va fsblkcnt_t Ta file system block counts Ta -
92.It Va fsfilcnt_t Ta file system file counts Ta -
93.It Va gid_t Ta group IDs Ta Xr getgid 2
94.It Va id_t Ta general identifier Ta Xr pset 3
95.It Va ino_t Ta file serial numbers Ta Xr fs 5
96.It Va key_t Ta interprocess communication Ta Xr ftok 3
97.It Va mode_t Ta file attributes Ta Xr stat 2
98.It Va nlink_t Ta link counts Ta Xr stat 2
99.It Va off_t Ta file sizes Ta Xr fseek 3
100.It Va pid_t Ta process and process group IDs Ta Xr getpid 2
101.It Va size_t Ta size of objects Ta Xr stddef 3
102.It Va ssize_t Ta count of bytes Ta Xr write 2
103.It Va suseconds_t Ta microseconds Ta Xr gettimeofday 2
104.It Va time_t Ta time in seconds Ta Xr time 3
105.It Va timer_t Ta timer IDs Ta Xr timer_create 2
106.\"
107.\" XXX: Following are undefined in NetBSD at the time of writing:
108.\"
109.\".It Va trace_attr_t Ta trace stream attributes Ta -
110.\".It Va trace_event_id_t Ta trace event type Ta -
111.\".It Va trace_event_set_t Ta trace event type set Ta -
112.\".It Va trace_id_t Ta trace stream ID Ta -
113.It Va uid_t Ta user IDs Ta Xr setuid 2
114.It Va useconds_t Ta time in microseconds Ta Xr usleep 3
115.El
116.Pp
117In addition, when included in user applications,
118.In sys/types.h
119includes
120.In pthread.h ,
121and thus it defines also the types used in the
122.Tn POSIX
123Threads Library,
124.Xr pthread 3 .
125.Pp
126Each described type may vary across machines and operating systems.
127Only the following properties are guaranteed by the
128.St -p1003.1-2001
129standard:
130.Bl -enum -offset indent
131.It
132The type
133.Em ssize_t
134is capable of storing integer values at least in the range [\-1,
135.Dv SSIZE_MAX ] .
136.It
137The type
138.Em useconds_t
139is an unsigned integer capable of storing
140values at least in the range [0, 1000000].
141.It
142The type
143.Em suseconds_t
144is a signed integer capable of storing
145values at least in the range [\-1, 1000000].
146.It
147The
148.Em time_t
149and
150.Em clock_t
151types are either integers or real-floating types.
152.It
153The following types are integers:
154.Em gid_t ,
155.Em id_t ,
156.Em mode_t ,
157.Em nlink_t ,
158and
159.Em uid_t .
160.It
161The following types are signed integers:
162.Em blkcnt_t ,
163.Em blksize_t ,
164.Em off_t ,
165.Em pid_t ,
166and
167.Em ssize_t .
168.It
169The following types are unsigned integers:
170.Em fsblkcnt_t ,
171.Em fsfilcnt_t ,
172.Em ino_t ,
173and
174.Em size_t .
175.El
176.Ss NetBSD-specific Types
177In addition to the standard types,
178.In sys/types.h
179defines some data types specific to
180.Nx .
181These are mostly used in the kernel.
182A portable implementation should not rely
183on these types to be available in other systems.
184Examples include:
185.Bl -column -offset indent \
186"suseconds_t " "synonym for uint64_t   " "getdevmajor(3) "
187.It Sy Type Ta Sy Typical use Ta Sy Example
188.It Va cpuid_t Ta CPU IDs Ta Xr cpuset 3
189.It Va daddr_t Ta disk address Ta Xr buffercache 9
190.It Va devmajor_t Ta major device number Ta Xr getdevmajor 3
191.It Va lwp_t Ta typedef of Va struct lwp Ta Xr kthread 9
192.It Va u_quad_t Ta synonym for Va uint64_t Ta Xr strtouq 3
193.El
194.Pp
195It can be noted that the standard
196.Dq C99 types
197described in
198.Xr stdint 3
199are preferred to the older fixed size integer types prefixed with an
200.Dq u_
201(in other words,
202.Va uint32_t
203should be used instead of
204.Va u_int32_t ) .
205.Sh SEE ALSO
206.Xr param 3 ,
207.Xr stdbool 3 ,
208.Xr stddef 3 ,
209.Xr stdint 3 ,
210.Xr stdlib 3 ,
211.Xr unistd 3
212.Sh STANDARDS
213The
214.In sys/types.h
215header conforms to
216.St -p1003.1-2001
217with respect to the described standard types.
218.Sh HISTORY
219The
220.In sys/types.h
221header first appeared in
222.At v7 .
223In the current form the header appeared in
224.Nx 0.9 .
225