root/include/asm-i386/unistd.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. _syscall0

   1 #ifndef _ASM_I386_UNISTD_H_
   2 #define _ASM_I386_UNISTD_H_
   3 
   4 /* XXX - _foo needs to be __foo, while __NR_bar could be _NR_bar. */
   5 #define _syscall0(type,name) \
   6 type name(void) \
   7 { \
   8 long __res; \
   9 __asm__ volatile ("int $0x80" \
  10         : "=a" (__res) \
  11         : "0" (__NR_##name)); \
  12 if (__res >= 0) \
  13         return (type) __res; \
  14 errno = -__res; \
  15 return -1; \
  16 }
  17 
  18 #define _syscall1(type,name,type1,arg1) \
  19 type name(type1 arg1) \
  20 { \
  21 long __res; \
  22 __asm__ volatile ("int $0x80" \
  23         : "=a" (__res) \
  24         : "0" (__NR_##name),"b" ((long)(arg1))); \
  25 if (__res >= 0) \
  26         return (type) __res; \
  27 errno = -__res; \
  28 return -1; \
  29 }
  30 
  31 #define _syscall2(type,name,type1,arg1,type2,arg2) \
  32 type name(type1 arg1,type2 arg2) \
  33 { \
  34 long __res; \
  35 __asm__ volatile ("int $0x80" \
  36         : "=a" (__res) \
  37         : "0" (__NR_##name),"b" ((long)(arg1)),"c" ((long)(arg2))); \
  38 if (__res >= 0) \
  39         return (type) __res; \
  40 errno = -__res; \
  41 return -1; \
  42 }
  43 
  44 #define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
  45 type name(type1 arg1,type2 arg2,type3 arg3) \
  46 { \
  47 long __res; \
  48 __asm__ volatile ("int $0x80" \
  49         : "=a" (__res) \
  50         : "0" (__NR_##name),"b" ((long)(arg1)),"c" ((long)(arg2)), \
  51                   "d" ((long)(arg3))); \
  52 if (__res>=0) \
  53         return (type) __res; \
  54 errno=-__res; \
  55 return -1; \
  56 }
  57 
  58 #define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
  59 type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
  60 { \
  61 long __res; \
  62 __asm__ volatile ("int $0x80" \
  63         : "=a" (__res) \
  64         : "0" (__NR_##name),"b" ((long)(arg1)),"c" ((long)(arg2)), \
  65           "d" ((long)(arg3)),"S" ((long)(arg4))); \
  66 if (__res>=0) \
  67         return (type) __res; \
  68 errno=-__res; \
  69 return -1; \
  70 } 
  71 
  72 #define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
  73           type5,arg5) \
  74 type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
  75 { \
  76 long __res; \
  77 __asm__ volatile ("int $0x80" \
  78         : "=a" (__res) \
  79         : "0" (__NR_##name),"b" ((long)(arg1)),"c" ((long)(arg2)), \
  80           "d" ((long)(arg3)),"S" ((long)(arg4)),"D" ((long)(arg5))); \
  81 if (__res>=0) \
  82         return (type) __res; \
  83 errno=-__res; \
  84 return -1; \
  85 }
  86 
  87 #ifdef __KERNEL_SYSCALLS__
  88 
  89 /*
  90  * we need this inline - forking from kernel space will result
  91  * in NO COPY ON WRITE (!!!), until an execve is executed. This
  92  * is no problem, but for the stack. This is handled by not letting
  93  * main() use the stack at all after fork(). Thus, no function
  94  * calls - which means inline code for fork too, as otherwise we
  95  * would use the stack upon exit from 'fork()'.
  96  *
  97  * Actually only pause and fork are needed inline, so that there
  98  * won't be any messing with the stack from main(), but we define
  99  * some others too.
 100  */
 101 #define __NR__exit __NR_exit
 102 static inline _syscall0(int,idle)
     /* [previous][next][first][last][top][bottom][index][help] */
 103 static inline _syscall0(int,fork)
 104 static inline _syscall0(int,pause)
 105 static inline _syscall0(int,setup)
 106 static inline _syscall0(int,sync)
 107 static inline _syscall0(pid_t,setsid)
 108 static inline _syscall3(int,write,int,fd,const char *,buf,off_t,count)
 109 static inline _syscall1(int,dup,int,fd)
 110 static inline _syscall3(int,execve,const char *,file,char **,argv,char **,envp)
 111 static inline _syscall3(int,open,const char *,file,int,flag,int,mode)
 112 static inline _syscall1(int,close,int,fd)
 113 static inline _syscall1(int,_exit,int,exitcode)
 114 static inline _syscall3(pid_t,waitpid,pid_t,pid,int *,wait_stat,int,options)
 115 
 116 static inline pid_t wait(int * wait_stat)
 117 {
 118         return waitpid(-1,wait_stat,0);
 119 }
 120 
 121 #endif
 122 
 123 #endif /* _ASM_I386_UNISTD_H_ */

/* [previous][next][first][last][top][bottom][index][help] */