TYPES(5) — UNIX Programmer’s Manual
NAME
types − primitive system data types
SYNOPSIS
#include <sys/types.h>
DESCRIPTION
The data types defined in the include file are used in UNIX system code; some data of these types are accessible to user code:
/∗
∗ $Header: types.5 1.1 89/11/06 $
∗
∗ types.h
∗Basic system types and major/minor device constructing/busting macros.
∗/
/∗ major part of a device ∗/
#definemajor(x)((int)(((unsigned)(x)>>16)&0xFFFF))
/∗ minor part of a device ∗/
#defineminor(x)((int)((x)&0xFFFF))
/∗ make a device number ∗/
#definemakedev(x,y)((dev_t)(((x)<<16) | (y)))
typedefunsigned charu_char;
typedefunsigned shortu_short;
typedefunsigned intu_int;
typedefunsigned longu_long;
typedefunsigned shortushort; /∗ sys III compat ∗/
/∗
∗ Savejmp/longjmp context. Also used in context switching.
∗/
#ifdefns32000
typedefstruct_physadr { int r[1]; } ∗physadr;
typedef structlabel_t {
intlt_r3;
intlt_r4;
intlt_r5;
intlt_r6;
intlt_r7;
intlt_fp;
intlt_sp;
intlt_pc;
} label_t;
#endifns32000
#ifdefi386
typedefstruct_physadr { int r[1]; } ∗physadr;
typedef structlabel_t {
intlt_esp;
intlt_ebp;
intlt_eip;
intlt_ebx;
intlt_esi;
intlt_edi;
} label_t;
#endifi386
typedefstruct_quad { long val[2]; } quad;
typedeflongdaddr_t;
typedefchar ∗caddr_t;
typedefu_longino_t;
typedeflongswblk_t;
typedefintsize_t;
typedeflongtime_t;
typedeflongdev_t;
typedefintoff_t;
typedefintbool_t;
typedefintspl_t;
typedef longkey_t; /∗ used for system V ipc ∗/
typedef u_shortuid_t;
typedef u_short gid_t;
/∗
∗ Select uses bit masks of file descriptors in longs.
∗ These macros manipulate such bit fields (the filesystem macros use chars).
∗ FD_SETSIZE may be defined by the user.
∗/
#ifndefFD_SETSIZE
#defineFD_SETSIZE256
#endif
typedeflongfd_mask;
#defineNFDBITS(sizeof(fd_mask) ∗ 8) /∗ bits per mask ∗/
#ifndefhowmany
#definehowmany(x, y)(((x)+((y)-1))/(y))
#endif
typedefstruct fd_set {
fd_maskfds_bits[howmany(FD_SETSIZE, NFDBITS)];
} fd_set;
#defineFD_SET(n, p)((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))
#defineFD_CLR(n, p)((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
#defineFD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
#define FD_ZERO(p)bzero((char ∗)(p), sizeof(∗(p)))
#defineFD_SET_SZ(n) (howmany((n), NFDBITS) ∗ sizeof(fd_mask))
/∗
∗ For mutex data-structures.
∗
∗ For ease of use for user-level code, we declare lock and sema struct’s
∗ here. More detail is in h/mutex.h and machine/mutex.h.
∗/
typedefunsigned chargate_t;
#ifdefns32000
typedefstruct{
gate_tl_gate;
charl_state;
} lock_t;
#endifns32000
#ifdefi386
typedefunsigned charlock_t;
#endifi386
#ifdefKERNEL
typedefstruct{
structproc∗s_head;
structproc∗s_tail;
shorts_count;
gate_ts_gate;
chars_flags;
} sema_t;
#else
/∗
∗ Version for lint and other user needs.
∗/
typedefstruct{
int∗s_head;
int∗s_tail;
shorts_count;
gate_ts_gate;
chars_flags;
} sema_t;
#endifKERNEL
#endif_TYPES_
The form daddr_t is used for disk addresses except in an i-node on disk, see fs(5). Times are encoded in seconds since 00:00:00 GMT, January 1, 1970. The major and minor parts of a device code specify kind and unit number of a device and are installation-dependent. Offsets are measured in bytes from the beginning of a file. The label_t variables are used to save the processor state while another process is running.
SEE ALSO
fs(5), time(3), lseek(2), ddt(1)
4BSD