home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 4 / DATAFILE_PDCD4.iso / unix / armlinux / alpha / PARTITIONS / USR_GZ / usr / include / arm / syscall.h < prev   
Encoding:
C/C++ Source or Header  |  1995-05-14  |  3.1 KB  |  120 lines

  1. #ifndef _ARM_SYSCALL_H
  2. #define _ARM_SYSCALL_H
  3.  
  4. #define __sys2(x) #x
  5. #define __sys1(x) __sys2(x)
  6. #define __syscall(name) "swi " __sys1(SYS_##name) "\n\t"
  7.  
  8. #define _syscall0(type,name)                    \
  9. type name(void)                            \
  10. {                                \
  11.   long __res;                            \
  12.   __asm__ __volatile__ (                    \
  13.   __syscall(name)                        \
  14.   "mov %0,r0\n\t"                        \
  15.   :"=r" (__res) : : "r0","r1","r2","r3");            \
  16.   if (__check_errno(__res))                    \
  17.     return (type) __res;                    \
  18.   errno = -__res;                        \
  19.   return -1;                            \
  20. }
  21.  
  22. #define _syscall1(type,name,atype,a)                \
  23. type name(atype a)                        \
  24. {                                \
  25.   long __res;                            \
  26.   __asm__ __volatile__ (                    \
  27.   "mov r0,%1\n\t"                        \
  28.   __syscall(name)                        \
  29.   "mov %0,r0\n\t"                        \
  30.     : "=r" (__res)                        \
  31.     : "r" ((long)(a)) : "r0","r1","r2","r3");        \
  32.   if(__check_errno(__res))                    \
  33.     return (type) __res;                    \
  34.   errno = -__res;                        \
  35.   return -1;                            \
  36. }
  37.  
  38. #define _syscall2(type,name,atype,a,btype,b)                \
  39. type name(atype a,btype b)                        \
  40. {                                    \
  41.   long __res;                                \
  42.   __asm__ __volatile__ (                        \
  43.   "mov r0,%1\n\t"                            \
  44.   "mov r1,%2\n\t"                            \
  45.   __syscall(name)                            \
  46.   "mov %0,r0\n\t"                            \
  47.     : "=r" (__res)                            \
  48.     : "r" ((long)(a)),"r" ((long)(b)) : "r0","r1","r2","r3");    \
  49.   if (__check_errno(__res))                        \
  50.     return (type) __res;                        \
  51.   errno = -__res;                            \
  52.   return -1;                                \
  53. }
  54.  
  55. #define _syscall3(type,name,atype,a,btype,b,ctype,c)            \
  56. type name(atype a,btype b,ctype c)                    \
  57. {                                    \
  58.   long __res;                                \
  59.   __asm__ __volatile__ (                        \
  60.   "mov r0,%1\n\t"                            \
  61.   "mov r1,%2\n\t"                            \
  62.   "mov r2,%3\n\t"                            \
  63.   __syscall(name)                            \
  64.   "mov %0,r0\n\t"                            \
  65.     : "=r" (__res)                            \
  66.     : "r" ((long)(a)),"r" ((long)(b)),"r" ((long)(c))        \
  67.     : "r0","r1","r2","r3");                        \
  68.   if (__check_errno(__res))                        \
  69.     return (type) __res;                        \
  70.   errno=-__res;                                \
  71.   return -1;                                \
  72. }
  73.  
  74. #define _syscall4(type,name,atype,a,btype,b,ctype,c,dtype,d)        \
  75. type name (atype a, btype b, ctype c, dtype d)                \
  76. {                                    \
  77.   long __res;                                \
  78.   __asm__ __volatile__ (                        \
  79.   "mov r0,%1\n\t"                            \
  80.   "mov r1,%2\n\t"                            \
  81.   "mov r2,%3\n\t"                            \
  82.   "mov r3,%4\n\t"                            \
  83.   __syscall(name)                            \
  84.   "mov %0,r0\n\t"                            \
  85.     : "=r" (__res)                            \
  86.     : "r" ((long)(a)),"r" ((long)(b)),                \
  87.       "r" ((long)(c)),"r" ((long)(d))                \
  88.     : "r0","r1","r2","r3");                        \
  89.   if (__check_errno(__res))                        \
  90.     return (type) __res;                        \
  91.   errno=-__res;                                \
  92.   return -1;                                \
  93. }
  94.  
  95. #define _syscall5(type,name,atype,a,btype,b,ctype,c,dtype,d,etype,e) \
  96. type name (atype a,btype b,ctype c,dtype d,etype e)            \
  97. {                                    \
  98.   long __res;                                \
  99.   __asm__ __volatile__ (                        \
  100.   "mov r0,%1\n\t"                            \
  101.   "mov r1,%2\n\t"                            \
  102.   "mov r2,%3\n\t"                            \
  103.   "str %5,[sp,#-4]!\n\t"                        \
  104.   "str %4,[sp,#-4]!\n\t"                        \
  105.   "mov r3,sp\n\t"                            \
  106.   __syscall(name)                            \
  107.   "mov %0,r0\n\t"                            \
  108.   "add sp,sp,#8\n\t"                            \
  109.     : "=r" (__res)                            \
  110.     : "r" ((long)(a)),"r" ((long)(b)),                \
  111.       "r" ((long)(c)),"r" ((long)(d)),"r" ((long)(e))        \
  112.     : "r0","r1","r2","r3");                        \
  113.   if (__check_errno(__res))                        \
  114.     return (type) __res;                        \
  115.   errno=-__res;                                \
  116.   return -1;                                \
  117. }
  118.  
  119. #endif /* _ARM_SYSCALL_H */
  120.