POSIX 标准头文件及unistd.h头文件说明

POSIX 标准头文件
noHeader fileDescriptionFirst released
1<assert.h>Verify assumptionsIssue 1
2<ctype.h>Character typesIssue 1
3<errno.h>Retrieving Error NumberIssue 1
4<fcntl.h>File opening, locking and other operationsIssue 1
5<ftw.h>File tree traversalIssue 1
6<grp.h>User group information and controlIssue 1
7<limits.h>Implementation-defined constants, see C data typesIssue 1
8<math.h>Mathematical declarations, see C mathematical functionsIssue 1
9<pwd.h>passwd (user information) access and controlIssue 1
10<search.h>Search tablesIssue 1
11<setjmp.h>Stack environment declarationsIssue 1
12<signal.h>Signals, see C signal handlingIssue 1
13<stdio.h>Standard buffered input/output, see C file input/outputIssue 1
14<string.h>Several String Operations, see C string handlingIssue 1
15<sys/stat.h>File information (stat et al.)Issue 1
16<sys/times.h>File access and modification timesIssue 1
17<sys/types.h>Various data types used elsewhereIssue 1
18<sys/utsname.h>Operating system information, including unameIssue 1
19<tgmath.h>Type-Generic Macros, see C mathematical functionsIssue 1
20<time.h>Type-Generic Macros, see C date and time functionsIssue 1
21<ulimit.h>Resource limiting (DEPRECATED in favor of <sys/resource.h>)Issue 1
22<unistd.h>Various essential POSIX functions and constantsIssue 1
23<dirent.h>Allows the opening and listing of directoriesIssue 2
24<langinfo.h>Language information constants – builds on C localization functionsIssue 2
25<nl_types.h>Localization message catalog functionsIssue 2
26<sys/ipc.h>Inter-process communication (IPC)Issue 2
27<sys/msg.h>POSIX message queuesIssue 2
28<sys/sem.h>XSI (SysV style) semaphoresIssue 2
29<sys/shm.h>XSI (SysV style) shared memoryIssue 2
30<cpio.h>Magic numbers for the cpio archive formatIssue 3
31<locale.h>Category macros, see C localization functionsIssue 3
32<stdlib.h>Standard library definitions, see C standard libraryIssue 3
33<sys/wait.h>Status of terminated child processes (see wait)Issue 3
34<tar.h>Magic numbers for the tar archive formatIssue 3
35<termios.h>Allows terminal I/O interfacesIssue 3
36<utime.h>inode access and modification timesIssue 3
37<float.h>Floating-point types, see C data typesIssue 4
38<fmtmsg.h>Message display structuresIssue 4
39<fnmatch.h>Filename matchingIssue 4
40<glob.h>Pathname “globbing” (pattern-matching)Issue 4
41<iconv.h>Codeset conversion facilityIssue 4
42<libgen.h>Pathname manipulationIssue 4
43<monetary.h>String formatting of monetary unitsIssue 4
44<ndbm.h>NDBM database operationsIssue 4
45<poll.h>Asynchronous file descriptor multiplexingIssue 4
46<regex.h>Regular expression matchingIssue 4
47<stdarg.h>Handle Variable Argument ListIssue 4
48<stddef.h>Standard type definitions, see C data typesIssue 4
49<strings.h>Case-insensitive string comparisonsIssue 4
50<stropts.h>Stream manipulation, including ioctlIssue 4
51<sys/mman.h>Memory management, including POSIX shared memory and memory mapped filesIssue 4
52<sys/resource.h>Resource usage, priorities, and limitingIssue 4
53<sys/statvfs.h>File System informationIssue 4
54<sys/time.h>Time and date functions and structuresIssue 4
55<sys/uio.h>Vectored I/O operationsIssue 4
56<syslog.h>System error loggingIssue 4
57<utmpx.h>User accounting database functionsIssue 4
58<wchar.h>Wide-Character Handling, see C string handlingIssue 4
59<wordexp.h>Word-expansion like the shell would performIssue 4
60<aio.h>Asynchronous input and outputIssue 5
61<dlfcn.h>Dynamic linkingIssue 5
62<inttypes.h>Fixed sized integer types, see C data typesIssue 5
63<iso646.h>Alternative spellings, see C alternative tokensIssue 5
64<mqueue.h>Message queueIssue 5
65<pthread.h>Defines an API for creating and manipulating POSIX threadsIssue 5
66<sched.h>Execution schedulingIssue 5
67<semaphore.h>POSIX semaphoresIssue 5
68<wctype.h>Wide-Character Classification and Mapping Utilities, see C character classificationIssue 5
69<arpa/inet.h>Functions for manipulating numeric IP addresses (part of Berkeley sockets)Issue 6
70<complex.h>Complex Arithmetic, see C mathematical functionsIssue 6
71<fenv.h>Floating-Point Environment (FPE), see C mathematical functionsIssue 6
72<net/if.h>Listing of local network interfacesIssue 6
73<netdb.h>Translating protocol and host names into numeric addresses (part of Berkeley sockets)Issue 6
74<netinet/in.h>Defines Internet protocol and address family (part of Berkeley sockets)Issue 6
75<netinet/tcp.h>Additional TCP control options (part of Berkeley sockets)Issue 6
76<spawn.h>Process spawningIssue 6
77<stdbool.h>Boolean type and values, see C data typesIssue 6
78<stdint.h>Integer types, see C data typesIssue 6
79<sys/select.h>Synchronous I/O multiplexingIssue 6
80<sys/socket.h>Main Berkeley sockets headerIssue 6
81<sys/un.h>Unix domain socketsIssue 6
82<trace.h>Tracing of runtime behavior (DEPRECATED)Issue 6

 

unistd.h
unistd.h 是 C 和 C++ 程序设计语言中提供对 POSIX 操作系统 API 的访问功能的头文件的名称。该头文件由 POSIX.1 标准(可移植系统接口)提出,故所有遵循该标准的操作系统和编译器均应提供该头文件(如 Unix 的所有官方版本,包括 Mac OS X、Linux 等)。
对于类 Unix 系统,unistd.h 中所定义的接口通常都是大量针对系统调用的封装(英语:wrapper functions),如 fork、pipe 以及各种 I/O 原语(read、write、close 等等)。

#ifndef _UNISTD_H
#define _UNISTD_H
#include <features.h>
#ifdef __cplusplus
extern "C" {
#endif
#include <_ansi.h>
#include <sys/types.h>
#include <sys/_types.h>
#define __need_size_t
#define __need_ptrdiff_t
#include <stddef.h>
extern char **environ;
void  _EXFUN(_exit, (int __status ) _ATTRIBUTE ((noreturn)));
int  _EXFUN(access,(const char *__path, int __amode ));
unsigned _EXFUN(alarm, (unsigned __secs ));
int   _EXFUN(chdir, (const char *__path ));
int   _EXFUN(chmod, (const char *__path, mode_t __mode ));
int   _EXFUN(chown, (const char *__path, uid_t __owner, gid_t __group ));
int   _EXFUN(chroot, (const char *__path ));
int   _EXFUN(close, (int __fildes ));
char  _EXFUN(*ctermid, (char *__s ));
char  _EXFUN(*cuserid, (char *__s ));
int   _EXFUN(dup, (int __fildes ));
int   _EXFUN(dup2, (int __fildes, int __fildes2 ));
int   _EXFUN(execl, (const char *__path, const char *, ... ));
int   _EXFUN(execle, (const char *__path, const char *, ... ));
int   _EXFUN(execlp, (const char *__file, const char *, ... ));
int   _EXFUN(execv, (const char *__path, char * const __argv[] ));
int   _EXFUN(execve, (const char *__path, char * const __argv[], char * const __envp[] ));
int   _EXFUN(execvp, (const char *__file, char * const __argv[] ));
int   _EXFUN(fchdir, (int __fildes));
int   _EXFUN(fchmod, (int __fildes, mode_t __mode ));
int   _EXFUN(fchown, (int __fildes, uid_t __owner, gid_t __group ));
pid_t  _EXFUN(fork, (void ));
long  _EXFUN(fpathconf, (int __fd, int __name ));
int   _EXFUN(fsync, (int __fd));
int   _EXFUN(ftruncate, (int __fd, off_t __length));
char  _EXFUN(*getcwd, (char *__buf, size_t __size ));
int  _EXFUN(getdomainname ,(char *__name, size_t __len));
gid_t  _EXFUN(getegid, (void ));
uid_t  _EXFUN(geteuid, (void ));
gid_t  _EXFUN(getgid, (void ));
int   _EXFUN(getgroups, (int __gidsetsize, gid_t __grouplist[] ));
int   _EXFUN(__gethostname, (char *__name, size_t __len));
char  _EXFUN(*getlogin, (void ));
#if defined(_POSIX_THREAD_SAFE_FUNCTIONS)
int _EXFUN(getlogin_r, (char *name, size_t namesize) );
#endif
char   _EXFUN(*getpass, (__const char *__prompt));
int _EXFUN(getpagesize, (void));
pid_t  _EXFUN(getpgid, (pid_t));
pid_t  _EXFUN(getpgrp, (void ));
pid_t  _EXFUN(getpid, (void ));
pid_t  _EXFUN(getppid, (void ));
uid_t  _EXFUN(getuid, (void ));
char *  _EXFUN(getusershell, (void));
char  _EXFUN(*getwd, (char *__buf ));
int   _EXFUN(isatty, (int __fildes ));
int   _EXFUN(lchown, (const char *__path, uid_t __owner, gid_t __group ));
int   _EXFUN(link, (const char *__path1, const char *__path2 ));
int  _EXFUN(nice, (int __nice_value ));
off_t  _EXFUN(lseek, (int __fildes, off_t __offset, int __whence ));
long  _EXFUN(pathconf, (const char *__path, int __name ));
int   _EXFUN(pause, (void ));
int   _EXFUN(pipe, (int __fildes[2] ));
ssize_t _EXFUN(pread, (int __fd, void *__buf, size_t __nbytes, off_t __offset));
ssize_t _EXFUN(pwrite, (int __fd, const void *__buf, size_t __nbytes, off_t __offset));
_READ_WRITE_RETURN_TYPE _EXFUN(read, (int __fd, void *__buf, size_t __nbyte ));
int   _EXFUN(readlink, (const char *path, char *buf, size_t bufsiz));
int   _EXFUN(rmdir, (const char *__path ));
void * _EXFUN(sbrk, (ptrdiff_t __incr));
int   _EXFUN(setegid, (gid_t __gid ));
int   _EXFUN(seteuid, (uid_t __uid ));
int   _EXFUN(setgid, (gid_t __gid ));
int   _EXFUN(setpgid, (pid_t __pid, pid_t __pgid ));
int   _EXFUN(setpgrp, (void ));
pid_t  _EXFUN(setsid, (void ));
int   _EXFUN(setuid, (uid_t __uid ));
unsigned _EXFUN(sleep, (unsigned int __seconds ));
void  _EXFUN(swab, (const void *, void *, ssize_t));
int   _EXFUN(symlink, (const char *oldpath, const char *newpath));
long  _EXFUN(sysconf, (int __name ));
pid_t  _EXFUN(tcgetpgrp, (int __fildes ));
int   _EXFUN(tcsetpgrp, (int __fildes, pid_t __pgrp_id ));
int   _EXFUN(truncate, (const char *, off_t __length));
char * _EXFUN(ttyname, (int __fildes ));
int   _EXFUN(ttyname_r, (int __fildes, char *__buf, size_t __len));
int   _EXFUN(unlink, (const char *__path ));
int   _EXFUN(usleep, (__useconds_t __useconds));
int   _EXFUN(vhangup, (void ));
_READ_WRITE_RETURN_TYPE _EXFUN(write, (int __fd, const void *__buf, size_t __nbyte ));
extern char *optarg;      /** getopt(3) external variables */
extern int optind, opterr, optopt;
int   getopt(int, char * const [], const char *);
extern int optreset;      /** getopt(3) external variable */
#ifndef    _POSIX_SOURCE
pid_t  _EXFUN(vfork, (void ));
extern char *suboptarg;      /** getsubopt(3) external variable */
int   getsubopt(char **, char * const *, char **);
#endif /** _POSIX_SOURCE */
/** Provide prototypes for most of the _<systemcall> names that are
provided in newlib for some compilers. */
int   _EXFUN(_close, (int __fildes ));
pid_t  _EXFUN(_fork, (void ));
pid_t  _EXFUN(_getpid, (void ));
int   _EXFUN(_link, (const char *__path1, const char *__path2 ));
off_t  _EXFUN(_lseek, (int __fildes, off_t __offset, int __whence ));
_READ_WRITE_RETURN_TYPE _EXFUN(_read, (int __fd, void *__buf, size_t __nbyte ));
void * _EXFUN(_sbrk, (size_t __incr));
int   _EXFUN(_unlink, (const char *__path ));
_READ_WRITE_RETURN_TYPE _EXFUN(_write, (int __fd, const void *__buf, size_t __nbyte ));
int   _EXFUN(_execve, (const char *__path, char * const __argv[], char * const __envp[] ));
#define  F_OK  0
#define  R_OK  4
#define  W_OK  2
#define  X_OK  1
# define  SEEK_SET  0
# define  SEEK_CUR  1
# define  SEEK_END  2
#include <sys/features.h>
#define STDIN_FILENO  0    /** standard input file descriptor */
#define STDOUT_FILENO  1    /** standard output file descriptor */
#define STDERR_FILENO  2    /** standard error file descriptor */
#include <bits/environments.h>
#include <bits/confname.h>
# define    MAXPATHLEN   1024
#ifdef __cplusplus
}
#endif
#endif /** _SYS_UNISTD_H *
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值