计算机 / 读书笔记 · 2021年12月19日 0

APIUE读书笔记chapter2

Unix标准

ISO C

最初由ANSI制定,为了C语言的通用性而订制的标准。现在大多数软件支持的都还是c99标准,但最新的标准是2011年的。99年引入了restrict关键字。
ISO C library,FreeBSD、Linux、Mac OS X、Solaris都支持:

HeaderDescription
assert.h断言
complex.h复数
ctype.hcharacter classification and mapping support
errno.h错误码
fenv.h浮点数环境
float.h浮点数常量和特性
inttypes.h整数类型转换
iso646.h赋值、关系运算、一元运算符相关的宏
limits.h实现中所使用的常量
locale.h语言环境相关
math.h数学函数、类型声明、常量
setjmp.h非局部跳转
signal.h信号
stdarg.h可变参数列表
stdbool.h布尔类型
stddef.h标准定义?
stdint.h整数类型
stdio.h标准输入输出
stdlib.h一些工具库函数
string.h字符串运算
tgmath.htype-generic math macros
time.h时间和日期
wchar.h多字节字符和宽字符
wctype.h宽字符分类和映射

IEEE POSIX

IEEE搞的标准,Portable Operating System Interface。所以就是为了方便应用程序在各操作系统间移植,定义了一套建议各操作系统都提供/遵循的接口(系统调用还是库函数都可以)。
POSIX标准中必须支持的接口:

HeaderDescription
aio.h异步IO
cpio.hcpio archive values
dirent.hdirectory entries
dlfcn.h动态链接
fcntl.h文件控制
fnmatch.h文件名匹配
glob.h路径模式匹配和生成
grp.hgroup file
iconv.h编码转换
langinfo.h语言信息常量
monetary.h钱的类型和函数?
netdb.h网络数据库操作
nl_types.hmessage catalogs
poll.hpoll函数
pthread.h线程
pwd.h密码文件
regex.h正则表达式
sched.h调度
semaphore.h信号量
strings.h字符串处理
tar.htar archive values
termios.h终端I/O
unistd.h符号常量
wordexp.hword-expansion definitions
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
arpa/inet.hInternet definitions
net/if.hsocket local interfaces
netinet/in.hInternet address family
netinet/tcp.hTransmission Control Protocol definitions
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
sys/mman.h内存管理声明
sys/select.hselect函数
sys/socket.h套接字函数
sys/stat.h文件信息
sys/statvfs.h文件系统信息
sys/times.h进程时间
sys/types.hprimitive system data types
sys/un.hUNIX domain socket definitions
sys/utsname.hsystem name
sys/wait.h进程控制

POSIX标准规定的可选头文件:

HeaderDescription
mqueue.hmessage queues
spawn.hreal-time spawn interface

X/Open System Interfaces(XSI)

The Single UNIX Specification是POSIX.1标准的超集。POSIX.1标准是XSI的Base Specifications portion。只有遵循了XSI标准的才能被称为UNIX。
POSIX标准规定的XSI选项头文件:

HeaderDescription
fmtmsg.hmessage display structures
ftw.hfile tree walking
libgen.hpathname management functions
ndbm.hdatabase operations
search.hsearch tables
syslog.hSystem error logging
utmpx.huser accounting database
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
sys/ipc.hIPC
sys/msg.hXSI message queues
sys/resource.hresource operations
sys/sem.hXSI semaphores
sys/shm.hXSI shared memory
sys/time.htime types
sys/uio.hvector I/O operations

FIPS

Federal Information Processing Standard.美国政府采购标准,貌似被废弃了?

UNIX 实现

  • SVR4
    UNIX System V Release 4。
  • 4.4BSD
  • FreeBSD
  • Linux
  • Mac OS X
  • Solaris
  • 其他

Limits

习题