root/include/asm-mips/unistd.h

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

INCLUDED FROM


   1 #ifndef __ASM_MIPS_UNISTD_H
   2 #define __ASM_MIPS_UNISTD_H
   3 
   4 #ifdef __KERNEL__
   5 
   6 #include <asm/mipsconfig.h>
   7 /*
   8  * Ugly kludge to enforce 32bit mode proof code.
   9  * Access errno via USEG, not KSEGx for internal kernel syscalls
  10  */
  11 #define errno (*(int *)((unsigned long)&errno - KERNELBASE))
  12 
  13 #endif /* __KERNEL__ */
  14 
  15 /* XXX - _foo needs to be __foo, while __NR_bar could be _NR_bar. */
  16 #define _syscall0(type,name) \
  17 type name(void) \
  18 { \
  19 register long __res __asm__ ("$2"); \
  20 __asm__ volatile ("syscall" \
  21                   : "=r" (__res) \
  22                   : "0" (__NR_##name)); \
  23 if (__res >= 0) \
  24         return (type) __res; \
  25 errno = -__res; \
  26 return -1; \
  27 }
  28 
  29 #define _syscall1(type,name,atype,a) \
  30 type name(atype a) \
  31 { \
  32 register long __res __asm__ ("$2"); \
  33 __asm__ volatile ("move\t$4,%2\n\t" \
  34                   "syscall" \
  35                   : "=r" (__res) \
  36                   : "0" (__NR_##name),"r" ((long)(a)) \
  37                   : "$4"); \
  38 if (__res >= 0) \
  39         return (type) __res; \
  40 errno = -__res; \
  41 return -1; \
  42 }
  43 
  44 #define _syscall2(type,name,atype,a,btype,b) \
  45 type name(atype a,btype b) \
  46 { \
  47 register long __res __asm__ ("$2"); \
  48 __asm__ volatile ("move\t$4,%2\n\t" \
  49                   "move\t$5,%3\n\t" \
  50                   "syscall" \
  51                   : "=r" (__res) \
  52                   : "0" (__NR_##name),"r" ((long)(a)), \
  53                                       "r" ((long)(b))); \
  54                   : "$4","$5"); \
  55 if (__res >= 0) \
  56         return (type) __res; \
  57 errno = -__res; \
  58 return -1; \
  59 }
  60 
  61 #define _syscall3(type,name,atype,a,btype,b,ctype,c) \
  62 type name (atype a, btype b, ctype c) \
  63 { \
  64 register long __res __asm__ ("$2"); \
  65 __asm__ volatile ("move\t$4,%2\n\t" \
  66                   "move\t$5,%3\n\t" \
  67                   "move\t$6,%4\n\t" \
  68                   "syscall" \
  69                   : "=r" (__res) \
  70                   : "0" (__NR_##name),"r" ((long)(a)), \
  71                                       "r" ((long)(b)), \
  72                                       "r" ((long)(c)) \
  73                   : "$4","$5","$6"); \
  74 if (__res>=0) \
  75         return (type) __res; \
  76 errno=-__res; \
  77 return -1; \
  78 }
  79 
  80 #define _syscall4(type,name,atype,a,btype,b,ctype,c,dtype,d) \
  81 type name (atype a, btype b, ctype c, dtype d) \
  82 { \
  83 register long __res __asm__ ("$2"); \
  84 __asm__ volatile (".set\tnoat\n\t" \
  85                   "move\t$4,%2\n\t" \
  86                   "move\t$5,%3\n\t" \
  87                   "move\t$6,%4\n\t" \
  88                   "move\t$7,%5\n\t" \
  89                   "syscall" \
  90                   : "=r" (__res) \
  91                   : "0" (__NR_##name),"r" ((long)(a)), \
  92                                       "r" ((long)(b)), \
  93                                       "r" ((long)(c)), \
  94                                       "r" ((long)(d)) \
  95                   : "$4","$5","$6","$7"); \
  96 if (__res>=0) \
  97         return (type) __res; \
  98 errno=-__res; \
  99 return -1; \
 100 }
 101 
 102 #define _syscall5(type,name,atype,a,btype,b,ctype,c,dtype,d,etype,e) \
 103 type name (atype a,btype b,ctype c,dtype d,etype e) \
 104 { \
 105 register long __res __asm__ ("$2"); \
 106 __asm__ volatile (".set\tnoat\n\t" \
 107                   "move\t$4,%2\n\t" \
 108                   "move\t$5,%3\n\t" \
 109                   "move\t$6,%4\n\t" \
 110                   "move\t$7,%5\n\t" \
 111                   "move\t$3,%6\n\t" \
 112                   "syscall" \
 113                   : "=r" (__res) \
 114                   : "0" (__NR_##name),"r" ((long)(a)), \
 115                                       "r" ((long)(b)), \
 116                                       "r" ((long)(c)), \
 117                                       "r" ((long)(d)), \
 118                                       "r" ((long)(e)) \
 119                   : "$3","$4","$5","$6","$7"); \
 120 if (__res>=0) \
 121         return (type) __res; \
 122 errno=-__res; \
 123 return -1; \
 124 }
 125 
 126 #endif /* __ASM_MIPS_UNISTD_H */

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