sysconf.cpp 816 B

123456789101112131415161718192021222324252627282930313233343536
  1. /*
  2. * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <Kernel/Process.h>
  7. #include <Kernel/Time/TimeManagement.h>
  8. namespace Kernel {
  9. KResultOr<FlatPtr> Process::sys$sysconf(int name)
  10. {
  11. VERIFY_NO_PROCESS_BIG_LOCK(this)
  12. switch (name) {
  13. case _SC_MONOTONIC_CLOCK:
  14. return 1;
  15. case _SC_NPROCESSORS_CONF:
  16. case _SC_NPROCESSORS_ONLN:
  17. return Processor::processor_count();
  18. case _SC_OPEN_MAX:
  19. return fds().max_open();
  20. case _SC_PAGESIZE:
  21. return PAGE_SIZE;
  22. case _SC_TTY_NAME_MAX:
  23. return TTY_NAME_MAX;
  24. case _SC_GETPW_R_SIZE_MAX:
  25. return 4096; // idk
  26. case _SC_CLK_TCK:
  27. return TimeManagement::the().ticks_per_second();
  28. default:
  29. return EINVAL;
  30. }
  31. }
  32. }