Team BBL
Previous Page Next Page

2.8. Primitive System Data Types

Historically, certain C data types have been associated with certain UNIX system variables. For example, the major and minor device numbers have historically been stored in a 16-bit short integer, with 8 bits for the major device number and 8 bits for the minor device number. But many larger systems need more than 256 values for these device numbers, so a different technique is needed. (Indeed, Solaris uses 32 bits for the device number: 14 bits for the major and 18 bits for the minor.)

The header <sys/types.h> defines some implementation-dependent data types, called the primitive system data types. More of these data types are defined in other headers also. These data types are defined in the headers with the C typedef facility. Most end in _t. Figure 2.20 lists many of the primitive system data types that we'll encounter in this text.

Figure 2.20. Some common primitive system data types

Type

Description

caddr_t

core address (Section 14.9)

clock_t

counter of clock ticks (process time) (Section 1.10)

comp_t

compressed clock ticks (Section 8.14)

dev_t

device numbers (major and minor) (Section 4.23)

fd_set

file descriptor sets (Section 14.5.1)

fpos_t

file position (Section 5.10)

gid_t

numeric group IDs

ino_t

i-node numbers (Section 4.14)

mode_t

file type, file creation mode (Section 4.5)

nlink_t

link counts for directory entries (Section 4.14)

off_t

file sizes and offsets (signed) (lseek, Section 3.6)

pid_t

process IDs and process group IDs (signed) (Sections 8.2 and 9.4)

ptrdiff_t

result of subtracting two pointers (signed)

rlim_t

resource limits (Section 7.11)

sig_atomic_t

data type that can be accessed atomically (Section 10.15)

sigset_t

signal set (Section 10.11)

size_t

sizes of objects (such as strings) (unsigned) (Section 3.7)

ssize_t

functions that return a count of bytes (signed) (read, write, Section 3.7)

time_t

counter of seconds of calendar time (Section 1.10)

uid_t

numeric user IDs

wchar_t

can represent all distinct character codes


By defining these data types this way, we do not build into our programs implementation details that can change from one system to another. We describe what each of these data types is used for when we encounter them later in the text.

    Team BBL
    Previous Page Next Page