missing_syscalls.c 896 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * Copyright 2012, Denys Vlasenko
  3. *
  4. * Licensed under GPLv2, see file LICENSE in this source tree.
  5. */
  6. //kbuild:lib-y += missing_syscalls.o
  7. #include "libbb.h"
  8. #if defined(ANDROID) || defined(__ANDROID__)
  9. /*# include <linux/timex.h> - for struct timex, but may collide with <time.h> */
  10. # include <sys/syscall.h>
  11. pid_t getsid(pid_t pid)
  12. {
  13. return syscall(__NR_getsid, pid);
  14. }
  15. int stime(const time_t *t)
  16. {
  17. struct timeval tv;
  18. tv.tv_sec = *t;
  19. tv.tv_usec = 0;
  20. return settimeofday(&tv, NULL);
  21. }
  22. int sethostname(const char *name, size_t len)
  23. {
  24. return syscall(__NR_sethostname, name, len);
  25. }
  26. struct timex;
  27. int adjtimex(struct timex *buf)
  28. {
  29. return syscall(__NR_adjtimex, buf);
  30. }
  31. int pivot_root(const char *new_root, const char *put_old)
  32. {
  33. return syscall(__NR_pivot_root, new_root, put_old);
  34. }
  35. # if __ANDROID_API__ < 21
  36. int tcdrain(int fd)
  37. {
  38. return ioctl(fd, TCSBRK, 1);
  39. }
  40. # endif
  41. #endif