root/include/asm-sparc/unistd.h

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

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. _syscall0

   1 #ifndef _SPARC_UNISTD_H
   2 #define _SPARC_UNISTD_H
   3 
   4 /*
   5  * System calls under the Sparc.
   6  *
   7  * Don't be scared by the ugly clobbers, it is the only way I can
   8  * think of right now to force the arguments into fixed registers
   9  * before the trap into the system call with gcc 'asm' statements.
  10  *
  11  * Copyright (C) 1994 David S. Miller (davem@caip.rutgers.edu)
  12  */
  13 
  14 /* XXX - _foo needs to be __foo, while __NR_bar could be _NR_bar. */
  15 #define _syscall0(type,name) \
  16 type name(void) \
  17 { \
  18 long __res; \
  19 __asm__ volatile ("or %%g0, %0, %%o0\n\t" \
  20                   "t 0xa\n\t" \
  21                   : "=r" (__res) \
  22                   : "0" (__NR_##name) \
  23                   : "o0"); \
  24 if (__res >= 0) \
  25     return (type) __res; \
  26 errno = -__res; \
  27 return -1; \
  28 }
  29 
  30 #define _syscall1(type,name,type1,arg1) \
  31 type name(type1 arg1) \
  32 { \
  33 long __res; \
  34 __asm__ volatile ("or %%g0, %0, %%o0\n\t" \
  35                   "or %%g0, %1, %%o1\n\t" \
  36                   "t 0xa\n\t" \
  37                   : "=r" (__res), "=r" ((long)(arg1)) \
  38                   : "0" (__NR_##name),"1" ((long)(arg1)) \
  39                   : "o0", "o1"); \
  40 if (__res >= 0) \
  41         return (type) __res; \
  42 errno = -__res; \
  43 return -1; \
  44 }
  45 
  46 #define _syscall2(type,name,type1,arg1,type2,arg2) \
  47 type name(type1 arg1,type2 arg2) \
  48 { \
  49 long __res; \
  50 __asm__ volatile ("or %%g0, %0, %%o0\n\t" \
  51                   "or %%g0, %1, %%o1\n\t" \
  52                   "or %%g0, %2, %%o2\n\t" \
  53                   "t 0xa\n\t" \
  54                   : "=r" (__res), "=r" ((long)(arg1)), "=r" ((long)(args)) \
  55                   : "0" (__NR_##name),"1" ((long)(arg1)),"2" ((long)(arg2)) \
  56                   : "o0", "o1", "o2"); \
  57 if (__res >= 0) \
  58         return (type) __res; \
  59 errno = -__res; \
  60 return -1; \
  61 }
  62 
  63 #define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
  64 type name(type1 arg1,type2 arg2,type3 arg3) \
  65 { \
  66 long __res; \
  67 __asm__ volatile ("or %%g0, %0, %%o0\n\t" \
  68                   "or %%g0, %1, %%o1\n\t" \
  69                   "or %%g0, %2, %%o2\n\t" \
  70                   "or %%g0, %3, %%o3\n\t" \
  71                   "t 0xa\n\t" \
  72                   : "=r" (__res), "=r" ((long)(arg1)), "=r" ((long)(arg2)), \
  73                     "=r" ((long)(arg3)) \
  74                   : "0" (__NR_##name), "1" ((long)(arg1)), "2" ((long)(arg2)), \
  75                     "3" ((long)(arg3)) \
  76                   : "o0", "o1", "o2", "o3"); \
  77 if (__res>=0) \
  78         return (type) __res; \
  79 errno=-__res; \
  80 return -1; \
  81 }
  82 
  83 #define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
  84 type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
  85 { \
  86 long __res; \
  87 __asm__ volatile ("or %%g0, %0, %%o0\n\t" \
  88                   "or %%g0, %1, %%o1\n\t" \
  89                   "or %%g0, %2, %%o2\n\t" \
  90                   "or %%g0, %3, %%o3\n\t" \
  91                   "or %%g0, %4, %%o4\n\t" \
  92                   "t 0xa\n\t" \
  93                   : "=r" (__res), "=r" ((long)(arg1)), "=r" ((long)(arg2)), \
  94                     "=r" ((long)(arg3)), "=r" ((long)(arg4)) \
  95                   : "0" (__NR_##name),"1" ((long)(arg1)),"2" ((long)(arg2)), \
  96                     "3" ((long)(arg3)),"4" ((long)(arg4)) \
  97                   : "o0", "o1", "o2", "o3", "o4"); \
  98 if (__res>=0) \
  99         return (type) __res; \
 100 errno=-__res; \
 101 return -1; \
 102 } 
 103 
 104 #define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
 105           type5,arg5) \
 106 type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
 107 { \
 108 long __res; \
 109 __asm__ volatile ("or %%g0, %0, %%o0\n\t" \
 110                   "or %%g0, %1, %%o1\n\t" \
 111                   "or %%g0, %2, %%o2\n\t" \
 112                   "or %%g0, %3, %%o3\n\t" \
 113                   "or %%g0, %4, %%o4\n\t" \
 114                   "or %%g0, %5, %%o5\n\t" \
 115                   "t 0xa\n\t" \
 116                   : "=r" (__res), "=r" ((long)(arg1)), "=r" ((long)(arg2)), \
 117                     "=r" ((long)(arg3)), "=r" ((long)(arg4)), "=r" ((long)(arg5)) \
 118                   : "0" (__NR_##name),"1" ((long)(arg1)),"2" ((long)(arg2)), \
 119                     "3" ((long)(arg3)),"4" ((long)(arg4)),"5" ((long)(arg5)) \
 120                   : "o0", "o1", "o2", "o3", "o4", "o5"); \
 121 if (__res>=0) \
 122         return (type) __res; \
 123 errno=-__res; \
 124 return -1; \
 125 }
 126 
 127 #ifdef __KERNEL_SYSCALLS__
 128 
 129 /*
 130  * we need this inline - forking from kernel space will result
 131  * in NO COPY ON WRITE (!!!), until an execve is executed. This
 132  * is no problem, but for the stack. This is handled by not letting
 133  * main() use the stack at all after fork(). Thus, no function
 134  * calls - which means inline code for fork too, as otherwise we
 135  * would use the stack upon exit from 'fork()'.
 136  *
 137  * Actually only pause and fork are needed inline, so that there
 138  * won't be any messing with the stack from main(), but we define
 139  * some others too.
 140  */
 141 #define __NR__exit __NR_exit
 142 static inline _syscall0(int,idle)
     /* [previous][next][first][last][top][bottom][index][help] */
 143 static inline _syscall0(int,fork)
 144 static inline _syscall0(int,pause)
 145 static inline _syscall0(int,setup)
 146 static inline _syscall0(int,sync)
 147 static inline _syscall0(pid_t,setsid)
 148 static inline _syscall3(int,write,int,fd,const char *,buf,off_t,count)
 149 static inline _syscall1(int,dup,int,fd)
 150 static inline _syscall3(int,execve,const char *,file,char **,argv,char **,envp)
 151 static inline _syscall3(int,open,const char *,file,int,flag,int,mode)
 152 static inline _syscall1(int,close,int,fd)
 153 static inline _syscall1(int,_exit,int,exitcode)
 154 static inline _syscall3(pid_t,waitpid,pid_t,pid,int *,wait_stat,int,options)
 155 
 156 static inline pid_t wait(int * wait_stat)
 157 {
 158         return waitpid(-1,wait_stat,0);
 159 }
 160 
 161 #endif
 162 
 163 #endif /* _SPARC_UNISTD_H */

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