mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 23:17:45 +00:00
LibC: Run constructors on process startup.
Cooperate with the compiler to generate and execute the _init_array list of constructor functions on userspace program statup. This took two days to get working, my goodness. :^)
This commit is contained in:
parent
f1a2cb0882
commit
23bb276fcd
22 changed files with 101 additions and 61 deletions
29
AK/kmalloc.h
29
AK/kmalloc.h
|
@ -1,5 +1,9 @@
|
|||
#pragma once
|
||||
|
||||
#ifndef KERNEL
|
||||
#include <new>
|
||||
#endif
|
||||
|
||||
#if defined(SERENITY) && defined(KERNEL)
|
||||
#define AK_MAKE_ETERNAL \
|
||||
public: \
|
||||
|
@ -23,6 +27,31 @@ void kfree(void* ptr);
|
|||
|
||||
}
|
||||
|
||||
#ifdef KERNEL
|
||||
inline void* operator new(size_t, void* p) { return p; }
|
||||
inline void* operator new[](size_t, void* p) { return p; }
|
||||
#else
|
||||
|
||||
inline void* operator new(size_t size)
|
||||
{
|
||||
return kmalloc(size);
|
||||
}
|
||||
|
||||
inline void operator delete(void* ptr)
|
||||
{
|
||||
return kfree(ptr);
|
||||
}
|
||||
|
||||
inline void* operator new[](size_t size)
|
||||
{
|
||||
return kmalloc(size);
|
||||
}
|
||||
|
||||
inline void operator delete[](void* ptr)
|
||||
{
|
||||
return kfree(ptr);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue