syscalls.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #ifndef _BITS_SYSCALLS_H
  2. #define _BITS_SYSCALLS_H
  3. #ifndef _SYSCALL_H
  4. # error "Never use <bits/syscall.h> directly; include <sys/syscall.h> instead."
  5. #endif
  6. #include <features.h>
  7. /* Do something very evil for now. Until we create our own syscall
  8. * macros, short circuit bits/syscall.h and use asm/unistd.h instead */
  9. #define _BITS_SYSCALL_H
  10. #include <asm/unistd.h>
  11. /* This includes the `__NR_<name>' syscall numbers taken from the Linux kernel
  12. * header files. It also defines the traditional `SYS_<name>' macros for older
  13. * programs. */
  14. #include <bits/syscall.h>
  15. /* The kernel includes don't provide _syscall6, so provide our own */
  16. #undef _syscall6
  17. #define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5,type6,arg6) \
  18. type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5, type6 arg6) \
  19. { \
  20. unsigned long __sc_ret, __sc_err; \
  21. { \
  22. register unsigned long __sc_0 __asm__ ("r0"); \
  23. register unsigned long __sc_3 __asm__ ("r3"); \
  24. register unsigned long __sc_4 __asm__ ("r4"); \
  25. register unsigned long __sc_5 __asm__ ("r5"); \
  26. register unsigned long __sc_6 __asm__ ("r6"); \
  27. register unsigned long __sc_7 __asm__ ("r7"); \
  28. register unsigned long __sc_8 __asm__ ("r8"); \
  29. \
  30. __sc_3 = (unsigned long) (arg1); \
  31. __sc_4 = (unsigned long) (arg2); \
  32. __sc_5 = (unsigned long) (arg3); \
  33. __sc_6 = (unsigned long) (arg4); \
  34. __sc_7 = (unsigned long) (arg5); \
  35. __sc_8 = (unsigned long) (arg6); \
  36. __sc_0 = __NR_##name; \
  37. __asm__ __volatile__ \
  38. ("sc \n\t" \
  39. "mfcr %1 " \
  40. : "=&r" (__sc_3), "=&r" (__sc_0) \
  41. : "0" (__sc_3), "1" (__sc_0), \
  42. "r" (__sc_4), \
  43. "r" (__sc_5), \
  44. "r" (__sc_6), \
  45. "r" (__sc_7), \
  46. "r" (__sc_8) \
  47. : __syscall_clobbers); \
  48. __sc_ret = __sc_3; \
  49. __sc_err = __sc_0; \
  50. } \
  51. __syscall_return (type); \
  52. }
  53. #endif /* _BITS_SYSCALLS_H */