| TYPES(3) | Library Functions Manual | TYPES(3) |
types — standard
system data types
#include
<sys/types.h>
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)).
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 IEEE Std 1003.1-2001 (“POSIX.1”) standard:
SSIZE_MAX].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).
param(3), stdbool(3), stddef(3), stdint(3), stdlib(3), unistd(3)
The <sys/types.h>
header conforms to IEEE Std 1003.1-2001
(“POSIX.1”) with respect to the described standard
types.
The <sys/types.h>
header first appeared in Version 7 AT&T
UNIX. In the current form the header appeared in
NetBSD 0.9.
| April 10, 2011 | NetBSD 11.0 |