syscalls.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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":\n\tli 0," __STRINGIFY(__NR_##name) "\n\t" \
  25. "b " __MAKE_SYSCALL "\n\t" \
  26. ".Lfe1" __STRINGIFY(name) ":\n\t" \
  27. ".size\t" __STRINGIFY(name) ",.Lfe1" __STRINGIFY(name) "-" __STRINGIFY(name) "\n" \
  28. )
  29. #undef _syscall0
  30. #define _syscall0(type,name) \
  31. type name(void); \
  32. unified_syscall_body(name)
  33. #undef _syscall1
  34. #define _syscall1(type,name,type1,arg1) \
  35. type name(type1 arg1); \
  36. unified_syscall_body(name)
  37. #undef _syscall2
  38. #define _syscall2(type,name,type1,arg1,type2,arg2) \
  39. type name(type1 arg1, type2 arg2); \
  40. unified_syscall_body(name)
  41. #undef _syscall3
  42. #define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
  43. type name(type1 arg1, type2 arg2, type3 arg3); \
  44. unified_syscall_body(name)
  45. #undef _syscall4
  46. #define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
  47. type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4); \
  48. unified_syscall_body(name)
  49. #undef _syscall5
  50. #define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5) \
  51. type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5); \
  52. unified_syscall_body(name)
  53. #undef _syscall6
  54. #define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5,type6,arg6) \
  55. type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5, type6 arg6); \
  56. unified_syscall_body(name)
  57. #endif /* _BITS_SYSCALLS_H */