unistd.h
来自「Linux Kernel 2.6.9 for OMAP1710」· C头文件 代码 · 共 478 行 · 第 1/2 页
H
478 行
/* User programs sometimes end up including this header file (indirectly, via uClibc header files), so I'm a bit nervous just including <linux/compiler.h>. */#if !defined(__builtin_expect) && __GNUC__ == 2 && __GNUC_MINOR__ < 96#define __builtin_expect(x, expected_value) (x)#endif#define __syscall_return(type, res) \ do { \ /* user-visible error numbers are in the range -1 - -124: \ see <asm-v850/errno.h> */ \ if (__builtin_expect ((unsigned long)(res) >= (unsigned long)(-125), 0)) { \ errno = -(res); \ res = -1; \ } \ return (type) (res); \ } while (0)#define _syscall0(type, name) \type name (void) \{ \ register unsigned long __syscall __asm__ (SYSCALL_NUM) = __NR_##name; \ register unsigned long __ret __asm__ (SYSCALL_RET); \ __asm__ __volatile__ ("trap " SYSCALL_SHORT_TRAP \ : "=r" (__ret), "=r" (__syscall) \ : "1" (__syscall) \ : SYSCALL_SHORT_CLOBBERS); \ __syscall_return (type, __ret); \}#define _syscall1(type, name, atype, a) \type name (atype a) \{ \ register atype __a __asm__ (SYSCALL_ARG0) = a; \ register unsigned long __syscall __asm__ (SYSCALL_NUM) = __NR_##name; \ register unsigned long __ret __asm__ (SYSCALL_RET); \ __asm__ __volatile__ ("trap " SYSCALL_SHORT_TRAP \ : "=r" (__ret), "=r" (__syscall) \ : "1" (__syscall), "r" (__a) \ : SYSCALL_SHORT_CLOBBERS); \ __syscall_return (type, __ret); \}#define _syscall2(type, name, atype, a, btype, b) \type name (atype a, btype b) \{ \ register atype __a __asm__ (SYSCALL_ARG0) = a; \ register btype __b __asm__ (SYSCALL_ARG1) = b; \ register unsigned long __syscall __asm__ (SYSCALL_NUM) = __NR_##name; \ register unsigned long __ret __asm__ (SYSCALL_RET); \ __asm__ __volatile__ ("trap " SYSCALL_SHORT_TRAP \ : "=r" (__ret), "=r" (__syscall) \ : "1" (__syscall), "r" (__a), "r" (__b) \ : SYSCALL_SHORT_CLOBBERS); \ __syscall_return (type, __ret); \}#define _syscall3(type, name, atype, a, btype, b, ctype, c) \type name (atype a, btype b, ctype c) \{ \ register atype __a __asm__ (SYSCALL_ARG0) = a; \ register btype __b __asm__ (SYSCALL_ARG1) = b; \ register ctype __c __asm__ (SYSCALL_ARG2) = c; \ register unsigned long __syscall __asm__ (SYSCALL_NUM) = __NR_##name; \ register unsigned long __ret __asm__ (SYSCALL_RET); \ __asm__ __volatile__ ("trap " SYSCALL_SHORT_TRAP \ : "=r" (__ret), "=r" (__syscall) \ : "1" (__syscall), "r" (__a), "r" (__b), "r" (__c) \ : SYSCALL_SHORT_CLOBBERS); \ __syscall_return (type, __ret); \}#define _syscall4(type, name, atype, a, btype, b, ctype, c, dtype, d) \type name (atype a, btype b, ctype c, dtype d) \{ \ register atype __a __asm__ (SYSCALL_ARG0) = a; \ register btype __b __asm__ (SYSCALL_ARG1) = b; \ register ctype __c __asm__ (SYSCALL_ARG2) = c; \ register dtype __d __asm__ (SYSCALL_ARG3) = d; \ register unsigned long __syscall __asm__ (SYSCALL_NUM) = __NR_##name; \ register unsigned long __ret __asm__ (SYSCALL_RET); \ __asm__ __volatile__ ("trap " SYSCALL_SHORT_TRAP \ : "=r" (__ret), "=r" (__syscall) \ : "1" (__syscall), \ "r" (__a), "r" (__b), "r" (__c), "r" (__d) \ : SYSCALL_SHORT_CLOBBERS); \ __syscall_return (type, __ret); \}#define _syscall5(type, name, atype, a, btype, b, ctype, c, dtype, d, etype,e)\type name (atype a, btype b, ctype c, dtype d, etype e) \{ \ register atype __a __asm__ (SYSCALL_ARG0) = a; \ register btype __b __asm__ (SYSCALL_ARG1) = b; \ register ctype __c __asm__ (SYSCALL_ARG2) = c; \ register dtype __d __asm__ (SYSCALL_ARG3) = d; \ register etype __e __asm__ (SYSCALL_ARG4) = e; \ register unsigned long __syscall __asm__ (SYSCALL_NUM) = __NR_##name; \ register unsigned long __ret __asm__ (SYSCALL_RET); \ __asm__ __volatile__ ("trap " SYSCALL_LONG_TRAP \ : "=r" (__ret), "=r" (__syscall), "=r" (__e) \ : "1" (__syscall), \ "r" (__a), "r" (__b), "r" (__c), "r" (__d), "2" (__e) \ : SYSCALL_CLOBBERS); \ __syscall_return (type, __ret); \}#if __GNUC__ < 3/* In older versions of gcc, `asm' statements with more than 10 input/output arguments produce a fatal error. To work around this problem, we use two versions, one for gcc-3.x and one for earlier versions of gcc (the `earlier gcc' version doesn't work with gcc-3.x because gcc-3.x doesn't allow clobbers to also be input arguments). */#define __SYSCALL6_TRAP(syscall, ret, a, b, c, d, e, f) \ __asm__ __volatile__ ("trap " SYSCALL_LONG_TRAP \ : "=r" (ret), "=r" (syscall) \ : "1" (syscall), \ "r" (a), "r" (b), "r" (c), "r" (d), \ "r" (e), "r" (f) \ : SYSCALL_CLOBBERS, SYSCALL_ARG4, SYSCALL_ARG5);#else /* __GNUC__ >= 3 */#define __SYSCALL6_TRAP(syscall, ret, a, b, c, d, e, f) \ __asm__ __volatile__ ("trap " SYSCALL_LONG_TRAP \ : "=r" (ret), "=r" (syscall), \ "=r" (e), "=r" (f) \ : "1" (syscall), \ "r" (a), "r" (b), "r" (c), "r" (d), \ "2" (e), "3" (f) \ : SYSCALL_CLOBBERS);#endif#define _syscall6(type, name, atype, a, btype, b, ctype, c, dtype, d, etype, e, ftype, f) \type name (atype a, btype b, ctype c, dtype d, etype e, ftype f) \{ \ register atype __a __asm__ (SYSCALL_ARG0) = a; \ register btype __b __asm__ (SYSCALL_ARG1) = b; \ register ctype __c __asm__ (SYSCALL_ARG2) = c; \ register dtype __d __asm__ (SYSCALL_ARG3) = d; \ register etype __e __asm__ (SYSCALL_ARG4) = e; \ register etype __f __asm__ (SYSCALL_ARG5) = f; \ register unsigned long __syscall __asm__ (SYSCALL_NUM) = __NR_##name; \ register unsigned long __ret __asm__ (SYSCALL_RET); \ __SYSCALL6_TRAP(__syscall, __ret, __a, __b, __c, __d, __e, __f); \ __syscall_return (type, __ret); \} #ifdef __KERNEL__#define __ARCH_WANT_IPC_PARSE_VERSION#define __ARCH_WANT_OLD_READDIR#define __ARCH_WANT_STAT64#define __ARCH_WANT_SYS_ALARM#define __ARCH_WANT_SYS_GETHOSTNAME#define __ARCH_WANT_SYS_PAUSE#define __ARCH_WANT_SYS_SGETMASK#define __ARCH_WANT_SYS_SIGNAL#define __ARCH_WANT_SYS_TIME#define __ARCH_WANT_SYS_UTIME#define __ARCH_WANT_SYS_WAITPID#define __ARCH_WANT_SYS_SOCKETCALL#define __ARCH_WANT_SYS_FADVISE64#define __ARCH_WANT_SYS_GETPGRP#define __ARCH_WANT_SYS_LLSEEK#define __ARCH_WANT_SYS_NICE#define __ARCH_WANT_SYS_OLDUMOUNT#define __ARCH_WANT_SYS_SIGPENDING#define __ARCH_WANT_SYS_SIGPROCMASK#define __ARCH_WANT_SYS_RT_SIGACTION#endif#ifdef __KERNEL_SYSCALLS__#include <linux/compiler.h>#include <linux/types.h>/* * we need this inline - forking from kernel space will result * in NO COPY ON WRITE (!!!), until an execve is executed. This * is no problem, but for the stack. This is handled by not letting * main() use the stack at all after fork(). Thus, no function * calls - which means inline code for fork too, as otherwise we * would use the stack upon exit from 'fork()'. * * Actually only pause and fork are needed inline, so that there * won't be any messing with the stack from main(), but we define * some others too. */#define __NR__exit __NR_exitextern inline _syscall0(pid_t,setsid)extern inline _syscall3(int,write,int,fd,const char *,buf,off_t,count)extern inline _syscall3(int,read,int,fd,char *,buf,off_t,count)extern inline _syscall3(off_t,lseek,int,fd,off_t,offset,int,count)extern inline _syscall1(int,dup,int,fd)extern inline _syscall3(int,execve,const char *,file,char **,argv,char **,envp)extern inline _syscall3(int,open,const char *,file,int,flag,int,mode)extern inline _syscall1(int,close,int,fd)extern inline _syscall1(int,_exit,int,exitcode)extern inline _syscall3(pid_t,waitpid,pid_t,pid,int *,wait_stat,int,options)extern inline pid_t wait(int * wait_stat){ return waitpid (-1, wait_stat, 0);}unsigned long sys_mmap(unsigned long addr, size_t len, unsigned long prot, unsigned long flags, unsigned long fd, off_t offset);unsigned long sys_mmap2(unsigned long addr, size_t len, unsigned long prot, unsigned long flags, unsigned long fd, unsigned long pgoff);struct pt_regs;int sys_execve (char *name, char **argv, char **envp, struct pt_regs *regs);int sys_pipe (int *fildes);int sys_ptrace(long request, long pid, long addr, long data);struct sigaction;asmlinkage long sys_rt_sigaction(int sig, const struct sigaction __user *act, struct sigaction __user *oact, size_t sigsetsize);#endif/* * "Conditional" syscalls */#define cond_syscall(name) \ asm (".weak\t" C_SYMBOL_STRING(name) ";" \ ".set\t" C_SYMBOL_STRING(name) "," C_SYMBOL_STRING(sys_ni_syscall));#if 0/* This doesn't work if there's a function prototype for NAME visible, because the argument types probably won't match. */#define cond_syscall(name) \ void name (void) __attribute__ ((weak, alias ("sys_ni_syscall")));#endif#endif /* __V850_UNISTD_H__ */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?