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

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