root/include/asm-sparc/unistd.h

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

INCLUDED FROM


   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 #endif /* _SPARC_UNISTD_H */

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