diff --git a/Kernel/API/Syscall.h b/Kernel/API/Syscall.h index c4ce0cb7ca..a05f7be98d 100644 --- a/Kernel/API/Syscall.h +++ b/Kernel/API/Syscall.h @@ -6,7 +6,6 @@ #pragma once -#include #include #include @@ -201,21 +200,6 @@ enum Function { __Count }; -constexpr StringView to_string(Function function) -{ - switch (function) { -#undef __ENUMERATE_SYSCALL -#define __ENUMERATE_SYSCALL(sys_call, needs_lock) \ - case SC_##sys_call: \ - return #sys_call##sv; - ENUMERATE_SYSCALLS(__ENUMERATE_SYSCALL) -#undef __ENUMERATE_SYSCALL - default: - break; - } - return "Unknown"sv; -} - #ifdef __serenity__ struct StringArgument { char const* characters; diff --git a/Kernel/API/SyscallString.h b/Kernel/API/SyscallString.h new file mode 100644 index 0000000000..6b9df75e78 --- /dev/null +++ b/Kernel/API/SyscallString.h @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2018-2022, Andreas Kling + * Copyright (c) 2022, Patrick Meyer + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#pragma once + +#include +#include + +namespace Kernel::Syscall { + +// Separate header so syscall.h doesn't depend on malloc. +// https://github.com/SerenityOS/serenity/issues/13869 +constexpr StringView to_string(Function function) +{ + switch (function) { +#undef __ENUMERATE_SYSCALL +#define __ENUMERATE_SYSCALL(sys_call, needs_lock) \ + case SC_##sys_call: \ + return #sys_call##sv; + ENUMERATE_SYSCALLS(__ENUMERATE_SYSCALL) +#undef __ENUMERATE_SYSCALL + default: + break; + } + return "Unknown"sv; +} + +} diff --git a/Tests/Kernel/fuzz-syscalls.cpp b/Tests/Kernel/fuzz-syscalls.cpp index ba06429a0c..8ec795a66b 100644 --- a/Tests/Kernel/fuzz-syscalls.cpp +++ b/Tests/Kernel/fuzz-syscalls.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include diff --git a/Userland/DevTools/UserspaceEmulator/Emulator_syscalls.cpp b/Userland/DevTools/UserspaceEmulator/Emulator_syscalls.cpp index fe90eff657..7b1cac737a 100644 --- a/Userland/DevTools/UserspaceEmulator/Emulator_syscalls.cpp +++ b/Userland/DevTools/UserspaceEmulator/Emulator_syscalls.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include diff --git a/Userland/Utilities/functrace.cpp b/Userland/Utilities/functrace.cpp index 6bfc19d081..b33d12858e 100644 --- a/Userland/Utilities/functrace.cpp +++ b/Userland/Utilities/functrace.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include diff --git a/Userland/Utilities/strace.cpp b/Userland/Utilities/strace.cpp index 7cc992baa1..762ea792e3 100644 --- a/Userland/Utilities/strace.cpp +++ b/Userland/Utilities/strace.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include diff --git a/Userland/Utilities/syscall.cpp b/Userland/Utilities/syscall.cpp index 7aab8b32a6..7c1e7ad17c 100644 --- a/Userland/Utilities/syscall.cpp +++ b/Userland/Utilities/syscall.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include