?? unistd.h
字號:
#ifndef _UNISTD_H#define _UNISTD_H/* ok, this may be a joke, but I'm working on it *//* ok, 這也許是個玩笑,但我正在著手處理 */// 下面符號常數(shù)指出符合IEEE 標(biāo)準(zhǔn)1003.1 實現(xiàn)的版本號,是一個整數(shù)值。#define _POSIX_VERSION 198808L// chown()和fchown()的使用受限于進(jìn)程的權(quán)限。/* 只有超級用戶可以執(zhí)行chown(我想..)*/#define _POSIX_CHOWN_RESTRICTED /* only root can do a chown (I think..) */// 長于(NAME_MAX)的路徑名將產(chǎn)生錯誤,而不會自動截斷。/* 路徑名不截斷(但是請看內(nèi)核代碼)*/#define _POSIX_NO_TRUNC /* no pathname truncation (but see in kernel) */// 下面這個符號將定義成字符值,該值將禁止終端對其的處理。/* 禁止象^C 這樣的字符 */#define _POSIX_VDISABLE '\0' /* character to disable things like ^C */// 每個進(jìn)程都有一保存的set-user-ID 和一保存的set-group-ID。 /* 我們將著手對此進(jìn)行處理 *//*#define _POSIX_SAVED_IDS *//* we'll get to this yet */// 系統(tǒng)實現(xiàn)支持作業(yè)控制。 /* 我們還沒有支持這項標(biāo)準(zhǔn),希望很快就行 *//*#define _POSIX_JOB_CONTROL *//* we aren't there quite yet. Soon hopefully */#define STDIN_FILENO 0 // 標(biāo)準(zhǔn)輸入文件句柄(描述符)號。#define STDOUT_FILENO 1 // 標(biāo)準(zhǔn)輸出文件句柄號。#define STDERR_FILENO 2 // 標(biāo)準(zhǔn)出錯文件句柄號。#ifndef NULL#define NULL ((void *)0) // 定義空指針。#endif/* access *//* 文件訪問 */// 以下定義的符號常數(shù)用于access()函數(shù)。#define F_OK 0 // 檢測文件是否存在。#define X_OK 1 // 檢測是否可執(zhí)行(搜索)。#define W_OK 2 // 檢測是否可寫。#define R_OK 4 // 檢測是否可讀。/* lseek *//* 文件指針重定位 */// 以下符號常數(shù)用于lseek()和fcntl()函數(shù)。#define SEEK_SET 0 // 將文件讀寫指針設(shè)置為偏移值。#define SEEK_CUR 1 // 將文件讀寫指針設(shè)置為當(dāng)前值加上偏移值。#define SEEK_END 2 // 將文件讀寫指針設(shè)置為文件長度加上偏移值。/* _SC stands for System Configuration. We don't use them much *//* _SC 表示系統(tǒng)配置。我們很少使用 */// 下面的符號常數(shù)用于sysconf()函數(shù)。#define _SC_ARG_MAX 1 // 最大變量數(shù)。#define _SC_CHILD_MAX 2 // 子進(jìn)程最大數(shù)。#define _SC_CLOCKS_PER_SEC 3 // 每秒滴答數(shù)。#define _SC_NGROUPS_MAX 4 // 最大組數(shù)。#define _SC_OPEN_MAX 5 // 最大打開文件數(shù)。#define _SC_JOB_CONTROL 6 // 作業(yè)控制。#define _SC_SAVED_IDS 7 // 保存的標(biāo)識符。#define _SC_VERSION 8 // 版本。/* more (possibly) configurable things - now pathnames *//* 更多的(可能的)可配置參數(shù) - 現(xiàn)在用于路徑名 */// 下面的符號常數(shù)用于pathconf()函數(shù)。#define _PC_LINK_MAX 1 // 連接最大數(shù)。#define _PC_MAX_CANON 2 // 最大常規(guī)文件數(shù)。#define _PC_MAX_INPUT 3 // 最大輸入長度。#define _PC_NAME_MAX 4 // 名稱最大長度。#define _PC_PATH_MAX 5 // 路徑最大長度。#define _PC_PIPE_BUF 6 // 管道緩沖大小。#define _PC_NO_TRUNC 7 // 文件名不截斷。#define _PC_VDISABLE 8 //#define _PC_CHOWN_RESTRICTED 9 // 改變宿主受限。#include <sys/stat.h> // 文件狀態(tài)頭文件。含有文件或文件系統(tǒng)狀態(tài)結(jié)構(gòu)stat{}和常量。#include <sys/times.h> // 定義了進(jìn)程中運行時間結(jié)構(gòu)tms 以及times()函數(shù)原型。#include <sys/utsname.h> // 系統(tǒng)名稱結(jié)構(gòu)頭文件。#include <utime.h> // 用戶時間頭文件。定義了訪問和修改時間結(jié)構(gòu)以及utime()原型。#ifdef __LIBRARY__// 以下是內(nèi)核實現(xiàn)的系統(tǒng)調(diào)用符號常數(shù),用于作為系統(tǒng)調(diào)用函數(shù)表中的索引值。( include/linux/sys.h )#define __NR_setup 0 /* used only by init, to get system going *//* __NR_setup 僅用于初始化,以啟動系統(tǒng) */#define __NR_exit 1#define __NR_fork 2#define __NR_read 3#define __NR_write 4#define __NR_open 5#define __NR_close 6#define __NR_waitpid 7#define __NR_creat 8#define __NR_link 9#define __NR_execve 11#define __NR_chdir 12#define __NR_time 13#define __NR_mknod 14#define __NR_chmod 15#define __NR_chown 16#define __NR_break 17#define __NR_stat 18#define __NR_lseek 19#define __NR_getpid 20#define __NR_mount 21#define __NR_umount 22#define __NR_setuid 23#define __NR_getuid 24#define __NR_stime 25#define __NR_ptrace 26#define __NR_alarm 27#define __NR_fstat 28#define __NR_pause 29#define __NR_utime 30#define __NR_stty 31#define __NR_gtty 32#define __NR_access 33#define __NR_nice 34#define __NR_ftime 35#define __NR_sync 36#define __NR_kill 37#define __NR_rename 38#define __NR_mkdir 39#define __NR_rmdir 40#define __NR_dup 41#define __NR_pipe 42#define __NR_times 43#define __NR_prof 44#define __NR_brk 45#define __NR_setgid 46#define __NR_getgid 47#define __NR_signal 48#define __NR_geteuid 49#define __NR_getegid 50#define __NR_acct 51#define __NR_phys 52#define __NR_lock 53#define __NR_ioctl 54#define __NR_fcntl 55#define __NR_mpx 56#define __NR_setpgid 57#define __NR_ulimit 58#define __NR_uname 59#define __NR_umask 60#define __NR_chroot 61#define __NR_ustat 62#define __NR_dup2 63#define __NR_getppid 64#define __NR_getpgrp 65#define __NR_setsid 66#define __NR_sigaction 67#define __NR_sgetmask 68#define __NR_ssetmask 69#define __NR_setreuid 70#define __NR_setregid 71// 以下定義系統(tǒng)調(diào)用嵌入式匯編宏函數(shù)。// 不帶參數(shù)的系統(tǒng)調(diào)用宏函數(shù)。type name(void)。// %0 - eax(__res),%1 - eax(__NR_##name)。其中name 是系統(tǒng)調(diào)用的名稱,與 __NR_ 組合形成上面// 的系統(tǒng)調(diào)用符號常數(shù),從而用來對系統(tǒng)調(diào)用表中函數(shù)指針尋址。// 返回:如果返回值大于等于0,則返回該值,否則置出錯號errno,并返回-1。#define _syscall0(type,name) \type name(void) \{ \long __res; \__asm__ volatile ( "int $0x80" \ // 調(diào)用系統(tǒng)中斷0x80。:"=a" (__res) \ // 返回值??eax(__res)。:"" (__NR_##name)); \ // 輸入為系統(tǒng)中斷調(diào)用號__NR_name。 if (__res >= 0) \ // 如果返回值>=0,則直接返回該值。 return (type) __res; errno = -__res; \ // 否則置出錯號,并返回-1。 return -1;}// 有1 個參數(shù)的系統(tǒng)調(diào)用宏函數(shù)。type name(atype a)// %0 - eax(__res),%1 - eax(__NR_name),%2 - ebx(a)。#define _syscall1(type,name,atype,a) \type name(atype a) \{ \long __res; \__asm__ volatile ( "int $0x80" \: "=a" (__res) \: "" (__NR_##name), "b" ((long)(a))); \if (__res >= 0) \return (type) __res; \errno = -__res; \return -1; \}// 有2 個參數(shù)的系統(tǒng)調(diào)用宏函數(shù)。type name(atype a, btype b)// %0 - eax(__res),%1 - eax(__NR_name),%2 - ebx(a),%3 - ecx(b)。#define _syscall2(type,name,atype,a,btype,b) \type name(atype a,btype b) \{ \long __res; \__asm__ volatile ( "int $0x80" \: "=a" (__res) \: "" (__NR_##name), "b" ((long)(a)), "c" ((long)(b))); \if (__res >= 0) \return (type) __res; \errno = -__res; \return -1; \}// 有3 個參數(shù)的系統(tǒng)調(diào)用宏函數(shù)。type name(atype a, btype b, ctype c)// %0 - eax(__res),%1 - eax(__NR_name),%2 - ebx(a),%3 - ecx(b),%4 - edx(c)。#define _syscall3(type,name,atype,a,btype,b,ctype,c) \type name(atype a,btype b,ctype c) \{ \long __res; \__asm__ volatile ( "int $0x80" \: "=a" (__res) \: "" (__NR_##name), "b" ((long)(a)), "c" ((long)(b)), "d" ((long)(c))); \if (__res>=0) \return (type) __res; \errno=-__res; \return -1; \}#endif /* __LIBRARY__ */ extern int errno; // 出錯號,全局變量。// 對應(yīng)各系統(tǒng)調(diào)用的函數(shù)原型定義。 int access (const char *filename, mode_t mode); int acct (const char *filename); int alarm (int sec); int brk (void *end_data_segment); void *sbrk (ptrdiff_t increment); int chdir (const char *filename); int chmod (const char *filename, mode_t mode); int chown (const char *filename, uid_t owner, gid_t group); int chroot (const char *filename); int close (int fildes); int creat (const char *filename, mode_t mode); int dup (int fildes); int execve (const char *filename, char **argv, char **envp); int execv (const char *pathname, char **argv); int execvp (const char *file, char **argv); int execl (const char *pathname, char *arg0, ...); int execlp (const char *file, char *arg0, ...); int execle (const char *pathname, char *arg0, ...); volatile void exit (int status); volatile void _exit (int status); int fcntl (int fildes, int cmd, ...); int fork (void); int getpid (void); int getuid (void); int geteuid (void); int getgid (void); int getegid (void); int ioctl (int fildes, int cmd, ...); int kill (pid_t pid, int signal); int link (const char *filename1, const char *filename2); int lseek (int fildes, off_t offset, int origin); int mknod (const char *filename, mode_t mode, dev_t dev); int mount (const char *specialfile, const char *dir, int rwflag); int nice (int val); int open (const char *filename, int flag, ...); int pause (void); int pipe (int *fildes); int read (int fildes, char *buf, off_t count); int setpgrp (void); int setpgid (pid_t pid, pid_t pgid); int setuid (uid_t uid); int setgid (gid_t gid); void (*signal (int sig, void (*fn) (int))) (int); int stat (const char *filename, struct stat *stat_buf); int fstat (int fildes, struct stat *stat_buf); int stime (time_t * tptr); int sync (void); time_t time (time_t * tloc); time_t times (struct tms *tbuf); int ulimit (int cmd, long limit); mode_t umask (mode_t mask); int umount (const char *specialfile); int uname (struct utsname *name); int unlink (const char *filename); int ustat (dev_t dev, struct ustat *ubuf); int utime (const char *filename, struct utimbuf *times); pid_t waitpid (pid_t pid, int *wait_stat, int options); pid_t wait (int *wait_stat); int write (int fildes, const char *buf, off_t count); int dup2 (int oldfd, int newfd); int getppid (void); pid_t getpgrp (void); pid_t setsid (void);#endif
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -