sysctl.c 982 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /*
  2. * _sysctl() for uClibc
  3. *
  4. * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
  5. *
  6. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  7. */
  8. #include <sys/syscall.h>
  9. #if defined __NR__sysctl && (defined __USE_GNU || defined __USE_BSD)
  10. /* psm: including sys/sysctl.h would depend on kernel headers */
  11. struct __sysctl_args {
  12. int *name;
  13. int nlen;
  14. void *oldval;
  15. size_t *oldlenp;
  16. void *newval;
  17. size_t newlen;
  18. unsigned long __unused[4];
  19. };
  20. extern int sysctl (int *__name, int __nlen, void *__oldval,
  21. size_t *__oldlenp, void *__newval, size_t __newlen) __THROW;
  22. int sysctl(int *name, int nlen, void *oldval, size_t * oldlenp,
  23. void *newval, size_t newlen)
  24. {
  25. /* avoid initializing on the stack as gcc will call memset() */
  26. struct __sysctl_args args;
  27. args.name = name;
  28. args.nlen = nlen;
  29. args.oldval = oldval;
  30. args.oldlenp = oldlenp;
  31. args.newval = newval;
  32. args.newlen = newlen;
  33. return INLINE_SYSCALL(_sysctl, 1, &args);
  34. }
  35. #endif