1.\" $NetBSD: types.3,v 1.7 2020/06/08 17:28:10 sevan 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.Bl -column -offset indent \ 83"suseconds_t " "process and process group IDs " "clock_settime(3) " 84.It Sy Type Ta Sy Typical use Ta Sy Example 85.It Va blkcnt_t Ta file block counts Ta Xr stat 2 86.It Va blksize_t Ta block sizes Ta Xr stat 2 87.It Va clock_t Ta system clock ticks Ta Xr clock 3 88.It Va clockid_t Ta clock IDs Ta Xr clock_settime 2 89.It Va dev_t Ta device IDs Ta Xr devname 3 90.It Va fsblkcnt_t Ta file system block counts Ta - 91.It Va fsfilcnt_t Ta file system file counts Ta - 92.It Va gid_t Ta group IDs Ta Xr getgid 2 93.It Va id_t Ta general identifier Ta Xr pset 3 94.It Va ino_t Ta file serial numbers Ta Xr fs 5 95.It Va key_t Ta interprocess communication Ta Xr ftok 3 96.It Va mode_t Ta file attributes Ta Xr stat 2 97.It Va nlink_t Ta link counts Ta Xr stat 2 98.It Va off_t Ta file sizes Ta Xr fseek 3 99.It Va pid_t Ta process and process group IDs Ta Xr getpid 2 100.It Va size_t Ta size of objects Ta Xr stddef 3 101.It Va ssize_t Ta count of bytes Ta Xr write 2 102.It Va suseconds_t Ta microseconds Ta Xr gettimeofday 2 103.It Va time_t Ta time in seconds Ta Xr time 3 104.It Va timer_t Ta timer IDs Ta Xr timer_create 2 105.\" 106.\" XXX: Following are undefined in NetBSD at the time of writing: 107.\" 108.\".It Va trace_attr_t Ta trace stream attributes Ta - 109.\".It Va trace_event_id_t Ta trace event type Ta - 110.\".It Va trace_event_set_t Ta trace event type set Ta - 111.\".It Va trace_id_t Ta trace stream ID Ta - 112.It Va uid_t Ta user IDs Ta Xr setuid 2 113.It Va useconds_t Ta time in microseconds Ta Xr usleep 3 114.El 115.Pp 116In addition, when included in user applications, 117.In sys/types.h 118includes 119.In pthread.h , 120and thus it defines also the types used in the 121.Tn POSIX 122Threads Library, 123.Xr pthread 3 . 124.Pp 125Each described type may vary across machines and operating systems. 126Only the following properties are guaranteed by the 127.St -p1003.1-2001 128standard: 129.Bl -enum -offset indent 130.It 131The type 132.Em ssize_t 133is capable of storing integer values at least in the range [\-1, 134.Dv SSIZE_MAX ] . 135.It 136The type 137.Em useconds_t 138is an unsigned integer capable of storing 139values at least in the range [0, 1000000]. 140.It 141The type 142.Em suseconds_t 143is a signed integer capable of storing 144values at least in the range [\-1, 1000000]. 145.It 146The 147.Em time_t 148and 149.Em clock_t 150types are either integers or real-floating types. 151.It 152The following types are integers: 153.Em gid_t , 154.Em id_t , 155.Em mode_t , 156.Em nlink_t , 157and 158.Em uid_t . 159.It 160The following types are signed integers: 161.Em blkcnt_t , 162.Em blksize_t , 163.Em off_t , 164.Em pid_t , 165and 166.Em ssize_t . 167.It 168The following types are unsigned integers: 169.Em fsblkcnt_t , 170.Em fsfilcnt_t , 171.Em ino_t , 172and 173.Em size_t . 174.El 175.Ss NetBSD-specific Types 176In addition to the standard types, 177.In sys/types.h 178defines some data types specific to 179.Nx . 180These are mostly used in the kernel. 181A portable implementation should not rely 182on these types to be available in other systems. 183Examples include: 184.Bl -column -offset indent \ 185"suseconds_t " "synonym for uint64_t " "getdevmajor(3) " 186.It Sy Type Ta Sy Typical use Ta Sy Example 187.It Va cpuid_t Ta CPU IDs Ta Xr cpuset 3 188.It Va daddr_t Ta disk address Ta Xr buffercache 9 189.It Va devmajor_t Ta major device number Ta Xr getdevmajor 3 190.It Va lwp_t Ta typedef of Va struct lwp Ta Xr kthread 9 191.It Va u_quad_t Ta synonym for Va uint64_t Ta Xr strtouq 3 192.El 193.Pp 194It can be noted that the standard 195.Dq C99 types 196described in 197.Xr stdint 3 198are preferred to the older fixed size integer types prefixed with an 199.Dq u_ 200(in other words, 201.Va uint32_t 202should be used instead of 203.Va u_int32_t ) . 204.Sh SEE ALSO 205.Xr param 3 , 206.Xr stdbool 3 , 207.Xr stddef 3 , 208.Xr stdint 3 , 209.Xr stdlib 3 , 210.Xr unistd 3 211.Sh STANDARDS 212The 213.In sys/types.h 214header conforms to 215.St -p1003.1-2001 216with respect to the described standard types. 217.Sh HISTORY 218The 219.In sys/types.h 220header first appeared in 221.At v7 . 222In the current form the header appeared in 223.Nx 0.9 . 224