mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:27:35 +00:00
Kernel: Pass trampolines instead of lambdas to create_kernel_process
With -Og, all calls to create_kernel_process were triggering -Wnonnull when creating these lambdas that get implicitly converted to function pointers. A different design of create_kernel_process to use AK::Function instead might avoid this awkward behavior.
This commit is contained in:
parent
6459c5a713
commit
86e3010043
2 changed files with 22 additions and 19 deletions
|
@ -151,17 +151,19 @@ public:
|
||||||
return current_thread ? ¤t_thread->process() : nullptr;
|
return current_thread ? ¤t_thread->process() : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename EntryFunction>
|
||||||
|
static void kernel_process_trampoline(void* data)
|
||||||
|
{
|
||||||
|
EntryFunction* func = reinterpret_cast<EntryFunction*>(data);
|
||||||
|
(*func)();
|
||||||
|
delete func;
|
||||||
|
}
|
||||||
|
|
||||||
template<typename EntryFunction>
|
template<typename EntryFunction>
|
||||||
static RefPtr<Process> create_kernel_process(RefPtr<Thread>& first_thread, String&& name, EntryFunction entry, u32 affinity = THREAD_AFFINITY_DEFAULT)
|
static RefPtr<Process> create_kernel_process(RefPtr<Thread>& first_thread, String&& name, EntryFunction entry, u32 affinity = THREAD_AFFINITY_DEFAULT)
|
||||||
{
|
{
|
||||||
auto* entry_func = new EntryFunction(move(entry));
|
auto* entry_func = new EntryFunction(move(entry));
|
||||||
return create_kernel_process(
|
return create_kernel_process(first_thread, move(name), &Process::kernel_process_trampoline<EntryFunction>, entry_func, affinity);
|
||||||
first_thread, move(name), [](void* data) {
|
|
||||||
EntryFunction* func = reinterpret_cast<EntryFunction*>(data);
|
|
||||||
(*func)();
|
|
||||||
delete func;
|
|
||||||
},
|
|
||||||
entry_func, affinity);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static RefPtr<Process> create_kernel_process(RefPtr<Thread>& first_thread, String&& name, void (*entry)(void*), void* entry_data = nullptr, u32 affinity = THREAD_AFFINITY_DEFAULT);
|
static RefPtr<Process> create_kernel_process(RefPtr<Thread>& first_thread, String&& name, void (*entry)(void*), void* entry_data = nullptr, u32 affinity = THREAD_AFFINITY_DEFAULT);
|
||||||
|
@ -805,7 +807,6 @@ inline ProcessID Thread::pid() const
|
||||||
VERIFY_NOT_REACHED(); \
|
VERIFY_NOT_REACHED(); \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline static String copy_string_from_user(const Kernel::Syscall::StringArgument& string)
|
inline static String copy_string_from_user(const Kernel::Syscall::StringArgument& string)
|
||||||
|
|
|
@ -9,20 +9,22 @@
|
||||||
|
|
||||||
namespace Kernel {
|
namespace Kernel {
|
||||||
|
|
||||||
|
static void finalizer_task(void*)
|
||||||
|
{
|
||||||
|
Thread::current()->set_priority(THREAD_PRIORITY_LOW);
|
||||||
|
for (;;) {
|
||||||
|
g_finalizer_wait_queue->wait_forever("FinalizerTask");
|
||||||
|
|
||||||
|
if (g_finalizer_has_work.exchange(false, AK::MemoryOrder::memory_order_acq_rel) == true)
|
||||||
|
Thread::finalize_dying_threads();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
void FinalizerTask::spawn()
|
void FinalizerTask::spawn()
|
||||||
{
|
{
|
||||||
RefPtr<Thread> finalizer_thread;
|
RefPtr<Thread> finalizer_thread;
|
||||||
Process::create_kernel_process(
|
auto finalizer_process = Process::create_kernel_process(finalizer_thread, "FinalizerTask", finalizer_task, nullptr);
|
||||||
finalizer_thread, "FinalizerTask", [](void*) {
|
VERIFY(finalizer_process);
|
||||||
Thread::current()->set_priority(THREAD_PRIORITY_LOW);
|
|
||||||
for (;;) {
|
|
||||||
g_finalizer_wait_queue->wait_forever("FinalizerTask");
|
|
||||||
|
|
||||||
if (g_finalizer_has_work.exchange(false, AK::MemoryOrder::memory_order_acq_rel) == true)
|
|
||||||
Thread::finalize_dying_threads();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
nullptr);
|
|
||||||
g_finalizer = finalizer_thread;
|
g_finalizer = finalizer_thread;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue