APUE学习——Ch2.Unix标准化与实现

Unix的标准化

1.ISO C的标准化

按照该标准定义的各个头文件,可将ISO C库分成24个区。POSIX.1标准包含这些头文件以及另一些头文件,(表中也列出了四种UNIX实现所支持的头文件):

Figure 2.1. Headers defined by the ISO C standard

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的标准库函数,还需要包含一些表中列出的头文件:

Figure 2.2. Required headers defined by the POSIX standard

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)


Figure 2.3. XSI extension headers defined by the POSIX standard

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)

Figure 2.4. Optional headers defined by the POSIX standard

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

3.Single UNIX Specification

Single UNIX Specification(单一UNIX规范)是POSIX.1标准的一个超集,定义了一些附加的接口,这些接口扩展了基本的POSIX.1规范所提供的功能,相应的系统接口全集被称为X/Open系统接口(XSI,X/Open System Interface)。

基本数据类型

头文件<sys/type.h>中定义了某些与实现有关的数据类型,它们被称为基本数据类型(primitive system data type)。

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 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



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
提供的源码资源涵盖了安卓应用、小程序、Python应用和Java应用等多个领域,每个领域都包含了丰富的实例和项目。这些源码都是基于各自平台的最新技术和标准编写,确保了在对应环境下能够无缝运行。同时,源码中配备了详细的注释和文档,帮助用户快速理解代码结构和实现逻辑。 适用人群: 这些源码资源特别适合大学生群体。无论你是计算机相关专业的学生,还是对其他领域编程感兴趣的学生,这些资源都能为你提供宝贵的学习和实践机会。通过学习和运行这些源码,你可以掌握各平台开发的基础知识,提升编程能力和项目实战经验。 使用场景及目标: 在学习阶段,你可以利用这些源码资源进行课程实践、课外项目或毕业设计。通过分析和运行源码,你将深入了解各平台开发的技术细节和最佳实践,逐步培养起自己的项目开发和问题解决能力。此外,在求职或创业过程中,具备跨平台开发能力的大学生将更具竞争力。 其他说明: 为了确保源码资源的可运行性和易用性,特别注意了以下几点:首先,每份源码都提供了详细的运行环境和依赖说明,确保用户能够轻松搭建起开发环境;其次,源码中的注释和文档都非常完善,方便用户快速上手和理解代码;最后,我会定期更新这些源码资源,以适应各平台技术的最新发展和市场需求。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值