Unix的标准化
1.ISO C的标准化
按照该标准定义的各个头文件,可将ISO C库分成24个区。POSIX.1标准包含这些头文件以及另一些头文件,(表中也列出了四种UNIX实现所支持的头文件):
Header | FreeBSD 5.2.1 | Linux 2.4.22 | Mac OS X 10.3 | Solaris 9 | Description |
---|---|---|---|---|---|
<assert.h> | • | • | • | • | verify program assertion |
<complex.h> | • | • | • | complex arithmetic support | |
<ctype.h> | • | • | • | • | character types |
<errno.h> | • | • | • | • | error codes (Section 1.7) |
<fenv.h> | • | • | floating-point environment | ||
<float.h> | • | • | • | • | floating-point constants |
<inttypes.h> | • | • | • | • | integer type format conversion |
<iso646.h> | • | • | • | • | alternate relational operator macros |
<limits.h> | • | • | • | • | implementation constants (Section 2.5) |
<locale.h> | • | • | • | • | locale categories |
<math.h> | • | • | • | • | mathematical constants |
<setjmp.h> | • | • | • | • | nonlocal goto (Section 7.10) |
<signal.h> | • | • | • | • | signals (Chapter 10) |
<stdarg.h> | • | • | • | • | variable argument lists |
<stdbool.h> | • | • | • | • | boolean type and values |
<stddef.h> | • | • | • | • | standard definitions |
<stdint.h> | • | • | • | integer types | |
<stdio.h> | • | • | • | • | standard I/O library (Chapter 5) |
<stdlib.h> | • | • | • | • | utility functions |
<string.h> | • | • | • | • | string operations |
<tgmath.h> | • | type-generic math macros | |||
<time.h> | • | • | • | • | time and date (Section 6.10) |
<wchar.h> | • | • | • | • | extended multibyte and wide character support |
<wctype.h> | • | • | • | • | wide character classification and mapping support |
2.IEEE POSIX
POSIX指的是可移植的操作系统接口(Portable Operating System Interface)。POSIX.1不仅包括ISO C的标准库函数,还需要包含一些表中列出的头文件:
Header | FreeBSD 5.2.1 | Linux 2.4.22 | Mac OS X 10.3 | Solaris 9 | Description |
---|---|---|---|---|---|
<dirent.h> | • | • | • | • | directory entries (Section 4.21) |
<fcntl.h> | • | • | • | • | file control (Section 3.14) |
<fnmatch.h> | • | • | • | • | filename-matching types |
<glob.h> | • | • | • | • | pathname pattern-matching types |
<grp.h> | • | • | • | • | group file (Section 6.4) |
<netdb.h> | • | • | • | • | network database operations |
<pwd.h> | • | • | • | • | password file (Section 6.2) |
<regex.h> | • | • | • | • | regular expressions |
<tar.h> | • | • | • | • | tar archive values |
<termios.h> | • | • | • | • | terminal I/O (Chapter 18) |
<unistd.h> | • | • | • | • | symbolic constants |
<utime.h> | • | • | • | • | file times (Section 4.19) |
<wordexp.h> | • | • | • | word-expansion types | |
<arpa/inet.h> | • | • | • | • | Internet definitions (Chapter 16) |
<net/if.h> | • | • | • | • | socket local interfaces (Chapter 16) |
<netinet/in.h> | • | • | • | • | Internet address family (Section 16.3) |
<netinet/tcp.h> | • | • | • | • | Transmission Control Protocol definitions |
<sys/mman.h> | • | • | • | • | memory management declarations |
<sys/select.h> | • | • | • | • | select function (Section 14.5.1) |
<sys/socket.h> | • | • | • | • | sockets interface (Chapter 16) |
<sys/stat.h> | • | • | • | • | file status (Chapter 4) |
<sys/times.h> | • | • | • | • | process times (Section 8.16) |
<sys/types.h> | • | • | • | • | primitive system data types (Section 2.8) |
<sys/un.h> | • | • | • | • | UNIX domain socket definitions (Section 17.3) |
<sys/utsname.h> | • | • | • | • | system name (Section 6.9) |
<sys/wait.h> | • | • | • | • | process control (Section 8.6) |
Header | FreeBSD 5.2.1 | Linux 2.4.22 | Mac OS X 10.3 | Solaris 9 | Description |
---|---|---|---|---|---|
<cpio.h> | • | • | • | cpio archive values | |
<dlfcn.h> | • | • | • | • | dynamic linking |
<fmtmsg.h> | • | • | • | message display structures | |
<ftw.h> | • | • | file tree walking (Section 4.21) | ||
<iconv.h> | • | • | • | codeset conversion utility | |
<langinfo.h> | • | • | • | • | language information constants |
<libgen.h> | • | • | • | • | definitions for pattern-matching function |
<monetary.h> | • | • | • | • | monetary types |
<ndbm.h> | • | • | • | database operations | |
<nl_types.h> | • | • | • | • | message catalogs |
<poll.h> | • | • | • | • | poll function (Section 14.5.2) |
<search.h> | • | • | • | • | search tables |
<strings.h> | • | • | • | • | string operations |
<syslog.h> | • | • | • | • | system error logging (Section 13.4) |
<ucontext.h> | • | • | • | • | user context |
<ulimit.h> | • | • | • | • | user limits |
<utmpx.h> | • | • | user accounting database | ||
<sys/ipc.h> | • | • | • | • | IPC (Section 15.6) |
<sys/msg.h> | • | • | • | message queues (Section 15.7) | |
<sys/resource.h> | • | • | • | • | resource operations (Section 7.11) |
<sys/sem.h> | • | • | • | • | semaphores (Section 15.8) |
<sys/shm.h> | • | • | • | • | shared memory (Section 15.9) |
<sys/statvfs.h> | • | • | • | file system information | |
<sys/time.h> | • | • | • | • | time types |
<sys/timeb.h> | • | • | • | • | additional date and time definitions |
<sys/uio.h> | • | • | • | • | vector I/O operations (Section 14.7) |
Header | FreeBSD 5.2.1 | Linux 2.4.22 | Mac OS X 10.3 | Solaris 9 | Description |
---|---|---|---|---|---|
<aio.h> | • | • | • | • | asynchronous I/O |
<mqueue.h> | • | • | message queues | ||
<pthread.h> | • | • | • | • | threads (Chapters 11 and 12) |
<sched.h> | • | • | • | • | execution scheduling |
<semaphore.h> | • | • | • | • | semaphores |
<spawn.h> | • | real-time spawn interface | |||
<stropts.h> | • | • | XSI STREAMS interface (Section 14.4) | ||
<trace.h> | event tracing |
Single UNIX Specification(单一UNIX规范)是POSIX.1标准的一个超集,定义了一些附加的接口,这些接口扩展了基本的POSIX.1规范所提供的功能,相应的系统接口全集被称为X/Open系统接口(XSI,X/Open System Interface)。
基本数据类型
头文件<sys/type.h>中定义了某些与实现有关的数据类型,它们被称为基本数据类型(primitive system data type)。
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 and9.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 |