SyscallString.h 768 B

1234567891011121314151617181920212223242526272829303132
  1. /*
  2. * Copyright (c) 2018-2022, Andreas Kling <kling@serenityos.org>
  3. * Copyright (c) 2022, Patrick Meyer <git@the-space.agency>
  4. *
  5. * SPDX-License-Identifier: BSD-2-Clause
  6. */
  7. #pragma once
  8. #include <AK/StringView.h>
  9. #include <Kernel/API/Syscall.h>
  10. namespace Kernel::Syscall {
  11. // Separate header so syscall.h doesn't depend on malloc.
  12. // https://github.com/SerenityOS/serenity/issues/13869
  13. constexpr StringView to_string(Function function)
  14. {
  15. switch (function) {
  16. #undef __ENUMERATE_SYSCALL
  17. #define __ENUMERATE_SYSCALL(sys_call, needs_lock) \
  18. case SC_##sys_call: \
  19. return #sys_call##sv;
  20. ENUMERATE_SYSCALLS(__ENUMERATE_SYSCALL)
  21. #undef __ENUMERATE_SYSCALL
  22. default:
  23. break;
  24. }
  25. return "Unknown"sv;
  26. }
  27. }