TYPES(3)

NAME
types - standard system data types

SYNOPSIS
#include <sys/types.h>

DESCRIPTION
The <sys/types.h> header contains the common data types used in the system. Although these are meant to be used within the kernel, most of the system data types are accessible also to user code. A companion header <sys/param.h>, typically used in the kernel, includes <sys/types.h> and provides additional types as well as other facilities (see param(3)).

  Standard Types
The following standards-compliant system data types are defined:
Type | Typical use | Example
blkcnt_t | file block counts | stat(2)
blksize_t | block sizes | stat(2)
clock_t | system clock ticks | clock(3)
clockid_t | clock IDs | clock_settime(2)
dev_t | device IDs | devname(3)
fsblkcnt_t | file system block counts | -
fsfilcnt_t | file system file counts | -
gid_t | group IDs | getgid(2)
id_t | general identifier | pset(3)
ino_t | file serial numbers | fs(5)
key_t | interprocess communication | ftok(3)
mode_t | file attributes | stat(2)
nlink_t | link counts | stat(2)
off_t | file sizes | fseek(3)
pid_t | process and process group IDs | getpid(2)
size_t | size of objects | stddef(3)
ssize_t | count of bytes | write(2)
suseconds_t | microseconds | gettimeofday(2)
time_t | time in seconds | time(3)
timer_t | timer IDs | timer_create(2)
uid_t | user IDs | setuid(2)
useconds_t | time in microseconds | usleep(3)

In addition, when included in user applications, <sys/types.h> includes <pthread.h>, and thus it defines also the types used in the POSIX Threads Library, pthread(3).

Each described type may vary across machines and operating systems. Only the following properties are guaranteed by the p1003.1-2001 standard:

1.  The type ssize_t is capable of storing integer values at least in the range [-1, SSIZE_MAX].

2.  The type useconds_t is an unsigned integer capable of storing values at least in the range [0, 1000000].

3.  The type suseconds_t is a signed integer capable of storing values at least in the range [-1, 1000000].

4.  The time_t and clock_t types are either integers or real-floating types.

5.  The following types are integers: gid_t, id_t, mode_t, nlink_t, and uid_t.

6.  The following types are signed integers: blkcnt_t, blksize_t, off_t, pid_t, and ssize_t.

7.  The following types are unsigned integers: fsblkcnt_t, fsfilcnt_t, ino_t, and size_t.

  NetBSD-specific Types
In addition to the standard types, <sys/types.h> defines some data types specific to NetBSD. These are mostly used in the kernel. A portable implementation should not rely on these types to be available in other systems. Examples include:
Type | Typical use | Example
cpuid_t | CPU IDs | cpuset(3)
daddr_t | disk address | buffercache(9)
devmajor_t | major device number | getdevmajor(3)
lwp_t | typedef of struct lwp | kthread(9)
u_quad_t | synonym for uint64_t | strtouq(3)

It can be noted that the standard “C99 types” described in stdint(3) are preferred to the older fixed size integer types prefixed with an “u_” (in other words, uint32_t should be used instead of u_int32_t).

SEE ALSO
param(3), stdbool(3), stddef(3), stdint(3), stdlib(3), unistd(3)

STANDARDS
The <sys/types.h> header conforms to p1003.1-2001 with respect to the described standard types.

HISTORY
The <sys/types.h> header first appeared in AT&T UNIX. In the current form the header appeared in NetBSD 0.9.