ld_syscalls.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #include <asm/unistd.h>
  2. /* Here are the macros which define how this platform makes
  3. * system calls. This particular variant does _not_ set
  4. * errno (note how it is disabled in __syscall_return) since
  5. * these will get called before the errno symbol is dynamicly
  6. * linked. */
  7. #undef __syscall_return
  8. #define __syscall_return(type, res) \
  9. do { \
  10. if ((unsigned long)(res) >= (unsigned long)(-125)) { \
  11. /*errno = -(res); */ \
  12. res = -1; \
  13. } \
  14. return (type) (res); \
  15. } while (0)
  16. #if defined(__PIC__)
  17. /*
  18. * PIC uses %ebx, so we need to save it during system calls
  19. */
  20. #undef _syscall1
  21. #define _syscall1(type,name,type1,arg1) \
  22. type name(type1 arg1) \
  23. { \
  24. long __res; \
  25. __asm__ volatile ("push %%ebx; movl %2,%%ebx; int $0x80; pop %%ebx" \
  26. : "=a" (__res) \
  27. : "0" (__NR_##name),"r" ((long)(arg1))); \
  28. __syscall_return(type,__res); \
  29. }
  30. #undef _syscall2
  31. #define _syscall2(type,name,type1,arg1,type2,arg2) \
  32. type name(type1 arg1,type2 arg2) \
  33. { \
  34. long __res; \
  35. __asm__ volatile ("push %%ebx; movl %2,%%ebx; int $0x80; pop %%ebx" \
  36. : "=a" (__res) \
  37. : "0" (__NR_##name),"r" ((long)(arg1)),"c" ((long)(arg2))); \
  38. __syscall_return(type,__res); \
  39. }
  40. #undef _syscall3
  41. #define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
  42. type name(type1 arg1,type2 arg2,type3 arg3) \
  43. { \
  44. long __res; \
  45. __asm__ volatile ("push %%ebx; movl %2,%%ebx; int $0x80; pop %%ebx" \
  46. : "=a" (__res) \
  47. : "0" (__NR_##name),"r" ((long)(arg1)),"c" ((long)(arg2)), \
  48. "d" ((long)(arg3))); \
  49. __syscall_return(type,__res); \
  50. }
  51. #undef _syscall4
  52. #define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
  53. type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
  54. { \
  55. long __res; \
  56. __asm__ volatile ("push %%ebx; movl %2,%%ebx; int $0x80; pop %%ebx" \
  57. : "=a" (__res) \
  58. : "0" (__NR_##name),"r" ((long)(arg1)),"c" ((long)(arg2)), \
  59. "d" ((long)(arg3)),"S" ((long)(arg4))); \
  60. __syscall_return(type,__res); \
  61. }
  62. #undef _syscall5
  63. #define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
  64. type5,arg5) \
  65. type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
  66. { \
  67. long __res; \
  68. __asm__ volatile ("push %%ebx; movl %2,%%ebx; int $0x80; pop %%ebx" \
  69. : "=a" (__res) \
  70. : "0" (__NR_##name),"m" ((long)(arg1)),"c" ((long)(arg2)), \
  71. "d" ((long)(arg3)),"S" ((long)(arg4)),"D" ((long)(arg5))); \
  72. __syscall_return(type,__res); \
  73. }
  74. #endif /* __PIC__ */