syscalls.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #ifndef _BITS_SYSCALLS_H
  2. #define _BITS_SYSCALLS_H
  3. #ifndef _SYSCALL_H
  4. # error "Never use <bits/syscalls.h> directly; include <sys/syscall.h> instead."
  5. #endif
  6. /* This includes the `__NR_<name>' syscall numbers taken from the Linux kernel
  7. * header files. It also defines the traditional `SYS_<name>' macros for older
  8. * programs. */
  9. #include <bits/sysnum.h>
  10. #define STRINGIFY(s) STRINGIFY2 (s)
  11. #define STRINGIFY2(s) #s
  12. #ifdef __PIC__
  13. #define JUMPTARGET(name) STRINGIFY(name##@plt)
  14. #else
  15. #define JUMPTARGET(name) STRINGIFY(name)
  16. #endif
  17. #define unified_syscall_body(name) \
  18. __asm__ ( \
  19. ".section \".text\"\n\t" \
  20. ".align 2\n\t" \
  21. ".globl "###name"\n\t" \
  22. ".type "###name",@function\n" \
  23. #name":\n\tli 0," STRINGIFY(__NR_##name) "\n\t" \
  24. "b "JUMPTARGET(__uClibc_syscall)"\n" \
  25. ".Lfe1"###name":\n\t" \
  26. ".size\t"###name ",.Lfe1"###name"-"###name"\n" \
  27. )
  28. #undef _syscall0
  29. #define _syscall0(type,name) \
  30. type name(void); \
  31. unified_syscall_body(name)
  32. #undef _syscall1
  33. #define _syscall1(type,name,type1,arg1) \
  34. type name(type1 arg1); \
  35. unified_syscall_body(name)
  36. #undef _syscall2
  37. #define _syscall2(type,name,type1,arg1,type2,arg2) \
  38. type name(type1 arg1, type2 arg2); \
  39. unified_syscall_body(name)
  40. #undef _syscall3
  41. #define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
  42. type name(type1 arg1, type2 arg2, type3 arg3); \
  43. unified_syscall_body(name)
  44. #undef _syscall4
  45. #define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
  46. type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4); \
  47. unified_syscall_body(name)
  48. #undef _syscall5
  49. #define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5) \
  50. type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5); \
  51. unified_syscall_body(name)
  52. #undef _syscall6
  53. #define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5,type6,arg6) \
  54. type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5, type6 arg6); \
  55. unified_syscall_body(name)
  56. #endif /* _BITS_SYSCALLS_H */