sysctl.c 815 B

123456789101112131415161718192021222324252627282930313233343536
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * _sysctl() for uClibc
  4. *
  5. * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
  6. *
  7. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  8. */
  9. #include <sys/syscall.h>
  10. #if defined __NR__sysctl && (defined __USE_GNU || defined __USE_BSD)
  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. int sysctl(int *name, int nlen, void *oldval, size_t * oldlenp,
  21. void *newval, size_t newlen)
  22. {
  23. /* avoid initializing on the stack as gcc will call memset() */
  24. struct __sysctl_args args;
  25. args.name = name;
  26. args.nlen = nlen;
  27. args.oldval = oldval;
  28. args.oldlenp = oldlenp;
  29. args.newval = newval;
  30. args.newlen = newlen;
  31. return INLINE_SYSCALL(_sysctl, 1, &args);
  32. }
  33. #endif