libroot: Introduce thread specific heap init/exit hooks.
This allows heap implementations to initialize and clean up any thread specific structures. The current default hoard heap does not use these. Note that the thread exit hook will not be called for the main thread as the heap may be needed during process termination (__cxa_finalize for example). Change-Id: I703fbd34dec0d9029d619a2125c5b19d8c1933aa Reviewed-on: https://review.haiku-os.org/799 Reviewed-by: waddlesplash <waddlesplash@gmail.com>
This commit is contained in:
parent
20e0f7607c
commit
e4103b1b92
@ -39,6 +39,8 @@ void __heap_terminate_after(void);
|
||||
void __heap_before_fork(void);
|
||||
void __heap_after_fork_child(void);
|
||||
void __heap_after_fork_parent(void);
|
||||
void __heap_thread_init(void);
|
||||
void __heap_thread_exit(void);
|
||||
|
||||
void __init_time(addr_t commPageTable);
|
||||
void __arch_init_time(struct real_time_data *data, bool setDefaults);
|
||||
|
@ -37,11 +37,13 @@ thread_entry(void* _entry, void* _thread)
|
||||
{
|
||||
thread_func entry = (thread_func)_entry;
|
||||
pthread_thread* thread = (pthread_thread*)_thread;
|
||||
status_t returnCode;
|
||||
|
||||
returnCode = entry(thread->entry_argument);
|
||||
__heap_thread_init();
|
||||
|
||||
status_t returnCode = entry(thread->entry_argument);
|
||||
|
||||
_thread_do_exit_work();
|
||||
__heap_thread_exit();
|
||||
|
||||
return returnCode;
|
||||
}
|
||||
@ -168,6 +170,7 @@ void
|
||||
exit_thread(status_t status)
|
||||
{
|
||||
_thread_do_exit_work();
|
||||
__heap_thread_exit();
|
||||
_kern_exit_thread(status);
|
||||
}
|
||||
|
||||
|
@ -285,6 +285,18 @@ __heap_after_fork_parent(void)
|
||||
}
|
||||
|
||||
|
||||
extern "C" void
|
||||
__heap_thread_init(void)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
extern "C" void
|
||||
__heap_thread_exit(void)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark - public functions
|
||||
|
||||
|
||||
|
@ -220,6 +220,18 @@ __heap_after_fork_parent(void)
|
||||
}
|
||||
|
||||
|
||||
extern "C" void
|
||||
__heap_thread_init(void)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
extern "C" void
|
||||
__heap_thread_exit(void)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark - Public API
|
||||
|
||||
|
||||
|
@ -40,6 +40,8 @@ pthread_thread_entry(void*, void* _thread)
|
||||
{
|
||||
pthread_thread* thread = (pthread_thread*)_thread;
|
||||
|
||||
__heap_thread_init();
|
||||
|
||||
pthread_exit(thread->entry(thread->entry_argument));
|
||||
return 0;
|
||||
}
|
||||
|
@ -880,6 +880,8 @@ void __heap_after_fork_child() {}
|
||||
void __heap_after_fork_parent() {}
|
||||
void __heap_before_fork() {}
|
||||
void __heap_terminate_after() {}
|
||||
void __heap_thread_init() {}
|
||||
void __heap_thread_exit() {}
|
||||
void __hypot() {}
|
||||
void __hypotf() {}
|
||||
void __hypotl() {}
|
||||
|
Loading…
x
Reference in New Issue
Block a user