sysconf.c 630 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #include <unistd.h>
  2. #include <limits.h>
  3. #include <time.h>
  4. #include <errno.h>
  5. #include <sys/limits.h>
  6. long
  7. sysconf(int name)
  8. {
  9. switch(name)
  10. {
  11. case _SC_ARG_MAX:
  12. return ARG_MAX;
  13. case _SC_CHILD_MAX:
  14. return CHILD_MAX;
  15. case _SC_CLK_TCK:
  16. return CLOCKS_PER_SEC;
  17. case _SC_NGROUPS_MAX:
  18. return NGROUPS_MAX;
  19. case _SC_OPEN_MAX:
  20. return OPEN_MAX;
  21. case _SC_JOB_CONTROL:
  22. #ifdef _POSIX_JOB_CONTROL
  23. return _POSIX_JOB_CONTROL;
  24. #else
  25. return -1;
  26. #endif
  27. case _SC_SAVED_IDS:
  28. #ifdef _POSIX_SAVED_IDS
  29. return _POSIX_SAVED_IDS;
  30. #else
  31. return -1;
  32. #endif
  33. case _SC_VERSION:
  34. return _POSIX_VERSION;
  35. }
  36. errno = EINVAL;
  37. return -1;
  38. }