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

  1. #ifndef _I386_SYSCALL_H
  2. #define _I386_SYSCALL_H
  3.  
  4. #define _syscall0(type,name) \
  5. type name(void) \
  6. { \
  7. long __res; \
  8. __asm__ __volatile__ ("int $0x80" \
  9.     : "=a" (__res) \
  10.     : "0" (SYS_##name)); \
  11. if (__check_errno(__res)) \
  12.     return (type) __res; \
  13. errno = -__res; \
  14. return -1; \
  15. }
  16.  
  17. #if defined(__PIC__) || defined (__pic__)
  18. #define _syscall1(type,name,atype,a) \
  19. type name(atype a) \
  20. { \
  21. long __res; \
  22. __asm__ __volatile__ ("pushl %%ebx\n\t" \
  23.           "movl %%ecx,%%ebx\n\t" \
  24.           "int $0x80\n\t" \
  25.           "popl %%ebx" \
  26.     : "=a" (__res) \
  27.     : "0" (SYS_##name),"c" ((long)(a)):"bx"); \
  28. if (__check_errno(__res)) \
  29.     return (type) __res; \
  30. errno = -__res; \
  31. return -1; \
  32. }
  33.  
  34. #define _syscall2(type,name,atype,a,btype,b) \
  35. type name(atype a,btype b) \
  36. { \
  37. long __res; \
  38. __asm__ __volatile__ ("pushl %%ebx\n\t" \
  39.           "movl %%edx,%%ebx\n\t" \
  40.           "int $0x80\n\t" \
  41.           "popl %%ebx" \
  42.     : "=a" (__res) \
  43.     : "0" (SYS_##name),"d" ((long)(a)),"c" ((long)(b)):"bx"); \
  44. if (__check_errno(__res)) \
  45.     return (type) __res; \
  46. errno = -__res; \
  47. return -1; \
  48. }
  49.  
  50. #define _syscall3(type,name,atype,a,btype,b,ctype,c) \
  51. type name(atype a,btype b,ctype c) \
  52. { \
  53. long __res; \
  54. __asm__ __volatile__ ("pushl %%ebx\n\t" \
  55.           "movl %%esi,%%ebx\n\t" \
  56.           "int $0x80\n\t" \
  57.           "popl %%ebx" \
  58.     : "=a" (__res) \
  59.     : "0" (SYS_##name),"S" ((long)(a)),"c" ((long)(b)),"d" ((long)(c)):"bx"); \
  60. if (__check_errno(__res)) \
  61.     return (type) __res; \
  62. errno=-__res; \
  63. return -1; \
  64. }
  65.  
  66. #define _syscall4(type,name,atype,a,btype,b,ctype,c,dtype,d) \
  67. type name (atype a, btype b, ctype c, dtype d) \
  68. { \
  69. long __res; \
  70. __asm__ __volatile__ ("pushl %%ebx\n\t" \
  71.           "movl %%edi,%%ebx\n\t" \
  72.           "int $0x80\n\t" \
  73.           "popl %%ebx" \
  74.     : "=a" (__res) \
  75.     : "0" (SYS_##name),"D" ((long)(a)),"c" ((long)(b)), \
  76.       "d" ((long)(c)),"S" ((long)(d))); \
  77. if (__check_errno(__res)) \
  78.     return (type) __res; \
  79. errno=-__res; \
  80. return -1; \
  81. }
  82.  
  83. #else    /* PIC */
  84.  
  85. #define _syscall1(type,name,atype,a) \
  86. type name(atype a) \
  87. { \
  88. long __res; \
  89. __asm__ __volatile__ ("int $0x80" \
  90.     : "=a" (__res) \
  91.     : "0" (SYS_##name),"b" ((long)(a)):"bx"); \
  92. if (__check_errno(__res)) \
  93.     return (type) __res; \
  94. errno = -__res; \
  95. return -1; \
  96. }
  97.  
  98. #define _syscall2(type,name,atype,a,btype,b) \
  99. type name(atype a,btype b) \
  100. { \
  101. long __res; \
  102. __asm__ __volatile__ ("int $0x80" \
  103.     : "=a" (__res) \
  104.     : "0" (SYS_##name),"b" ((long)(a)),"c" ((long)(b)):"bx"); \
  105. if (__check_errno(__res)) \
  106.     return (type) __res; \
  107. errno = -__res; \
  108. return -1; \
  109. }
  110.  
  111. #define _syscall3(type,name,atype,a,btype,b,ctype,c) \
  112. type name(atype a,btype b,ctype c) \
  113. { \
  114. long __res; \
  115. __asm__ __volatile__ ("int $0x80" \
  116.     : "=a" (__res) \
  117.     : "0" (SYS_##name),"b" ((long)(a)),"c" ((long)(b)),"d" ((long)(c)):"bx"); \
  118. if (__check_errno(__res)) \
  119.     return (type) __res; \
  120. errno=-__res; \
  121. return -1; \
  122. }
  123.  
  124. #define _syscall4(type,name,atype,a,btype,b,ctype,c,dtype,d) \
  125. type name (atype a, btype b, ctype c, dtype d) \
  126. { \
  127. long __res; \
  128. __asm__ __volatile__ ("int $0x80" \
  129.     : "=a" (__res) \
  130.     : "0" (SYS_##name),"b" ((long)(a)),"c" ((long)(b)), \
  131.       "d" ((long)(c)),"S" ((long)(d))); \
  132. if (__check_errno(__res)) \
  133.     return (type) __res; \
  134. errno=-__res; \
  135. return -1; \
  136. }
  137.  
  138. #define _syscall5(type,name,atype,a,btype,b,ctype,c,dtype,d,etype,e) \
  139. type name (atype a,btype b,ctype c,dtype d,etype e) \
  140. { \
  141. long __res; \
  142. __asm__ __volatile__ ("int $0x80" \
  143.     : "=a" (__res) \
  144.     : "0" (SYS_##name),"b" ((long)(a)),"c" ((long)(b)), \
  145.       "d" ((long)(c)),"S" ((long)(d)),"D" ((long)(e))); \
  146. if (__check_errno(__res)) \
  147.     return (type) __res; \
  148. errno=-__res; \
  149. return -1; \
  150. }
  151.  
  152. #endif    /* PIC */
  153.  
  154. #endif /* _I386_SYSCALL_H */
  155.