sysctl.c 1007 B

1234567891011121314151617181920212223242526272829303132333435363738
  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. /* psm: including sys/sysctl.h would depend on kernel headers */
  12. struct __sysctl_args {
  13. int *name;
  14. int nlen;
  15. void *oldval;
  16. size_t *oldlenp;
  17. void *newval;
  18. size_t newlen;
  19. unsigned long __unused[4];
  20. };
  21. extern int sysctl (int *__name, int __nlen, void *__oldval,
  22. size_t *__oldlenp, void *__newval, size_t __newlen) __THROW;
  23. int sysctl(int *name, int nlen, void *oldval, size_t * oldlenp,
  24. void *newval, size_t newlen)
  25. {
  26. /* avoid initializing on the stack as gcc will call memset() */
  27. struct __sysctl_args args;
  28. args.name = name;
  29. args.nlen = nlen;
  30. args.oldval = oldval;
  31. args.oldlenp = oldlenp;
  32. args.newval = newval;
  33. args.newlen = newlen;
  34. return INLINE_SYSCALL(_sysctl, 1, &args);
  35. }
  36. #endif