Kernel/LibC: Implement pthread_attr_init

This commit is contained in:
Bananymous 2025-04-15 23:19:55 +03:00
parent 4bcd3ed86f
commit 08f5833ca8
2 changed files with 13 additions and 3 deletions

View File

@ -2051,11 +2051,15 @@ namespace Kernel
BAN::ErrorOr<long> Process::sys_pthread_create(const pthread_attr_t* attr, void (*entry)(void*), void* arg) BAN::ErrorOr<long> Process::sys_pthread_create(const pthread_attr_t* attr, void (*entry)(void*), void* arg)
{ {
if (attr != nullptr) if (attr)
{
TRY(validate_pointer_access(attr, sizeof(*attr), false));
if (*attr)
{ {
dwarnln("pthread attr not supported"); dwarnln("pthread attr not supported");
return BAN::Error::from_errno(ENOTSUP); return BAN::Error::from_errno(ENOTSUP);
} }
}
LockGuard _(m_process_lock); LockGuard _(m_process_lock);

View File

@ -80,6 +80,12 @@ void pthread_cleanup_push(void (*routine)(void*), void* arg)
s_cleanup_stack = cleanup; s_cleanup_stack = cleanup;
} }
int pthread_attr_init(pthread_attr_t* attr)
{
*attr = 0;
return 0;
}
int pthread_create(pthread_t* __restrict thread_id, const pthread_attr_t* __restrict attr, void* (*start_routine)(void*), void* __restrict arg) int pthread_create(pthread_t* __restrict thread_id, const pthread_attr_t* __restrict attr, void* (*start_routine)(void*), void* __restrict arg)
{ {
auto* info = static_cast<pthread_trampoline_info_t*>(malloc(sizeof(pthread_trampoline_info_t))); auto* info = static_cast<pthread_trampoline_info_t*>(malloc(sizeof(pthread_trampoline_info_t)));