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. #undef JUMPTARGET
  13. #ifdef __PIC__
  14. #define __MAKE_SYSCALL __STRINGIFY(__uClibc_syscall@plt)
  15. #else
  16. #define __MAKE_SYSCALL __STRINGIFY(__uClibc_syscall)
  17. #endif
  18. #define unified_syscall_body(name) \
  19. __asm__ ( \
  20. ".section \".text\"\n\t" \
  21. ".align 2\n\t" \
  22. ".globl " __STRINGIFY(name) "\n\t" \
  23. ".type " __STRINGIFY(name) ",@function\n\t" \
  24. #name":\tli 0," __STRINGIFY(__NR_##name) "\n\t" \
  25. "b " __MAKE_SYSCALL "\n\t" \
  26. ".size\t" __STRINGIFY(name) ",.""-" __STRINGIFY(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 */