LibC: Fix pthread default guard size and name

This commit is contained in:
2026-07-13 23:55:49 +03:00
parent 6ebd3a8aca
commit bc622c8b51

View File

@@ -28,7 +28,7 @@ static pthread_attr_t s_default_pthread_attr {
.scope = PTHREAD_SCOPE_SYSTEM, .scope = PTHREAD_SCOPE_SYSTEM,
.stackaddr = nullptr, .stackaddr = nullptr,
.stacksize = 8 * 1024 * 1024, .stacksize = 8 * 1024 * 1024,
.guardsize = static_cast<size_t>(getpagesize()), .guardsize = 0,
}; };
static BAN::Atomic<struct uthread*> s_pending_uthread_deletion { nullptr }; static BAN::Atomic<struct uthread*> s_pending_uthread_deletion { nullptr };
@@ -46,6 +46,8 @@ static void _pthread_cancel_handler(int)
__attribute__((constructor)) __attribute__((constructor))
static void _init_pthread() static void _init_pthread()
{ {
s_default_pthread_attr.guardsize = getpagesize();
uthread* uthread = _get_uthread(); uthread* uthread = _get_uthread();
uthread->id = syscall(SYS_THREAD_GETID); uthread->id = syscall(SYS_THREAD_GETID);
uthread->attr = s_default_pthread_attr; uthread->attr = s_default_pthread_attr;
@@ -69,9 +71,9 @@ static void _init_pthread()
const char* last_slash = strrchr(buffer, '/'); const char* last_slash = strrchr(buffer, '/');
if (last_slash == nullptr) if (last_slash == nullptr)
last_slash = buffer; last_slash = buffer - 1;
strncpy(uthread->name, last_slash, sizeof(uthread->name)); strncpy(uthread->name, last_slash + 1, sizeof(uthread->name));
uthread->name[sizeof(uthread->name) - 1] = '\0'; uthread->name[sizeof(uthread->name) - 1] = '\0';
signal(SIGCANCEL, &_pthread_cancel_handler); signal(SIGCANCEL, &_pthread_cancel_handler);
@@ -742,11 +744,9 @@ int pthread_setcanceltype(int type, int* oldtype)
int pthread_getschedparam(pthread_t thread, int* __restrict policy, struct sched_param* __restrict param) int pthread_getschedparam(pthread_t thread, int* __restrict policy, struct sched_param* __restrict param)
{ {
(void)thread; *policy = thread->attr.schedpolicy;
(void)policy; *param = thread->attr.schedparam;
(void)param; return 0;
dwarnln("TODO: pthread_getschedparam");
return ENOTSUP;
} }
int pthread_setschedparam(pthread_t thread, int policy, const struct sched_param* param) int pthread_setschedparam(pthread_t thread, int policy, const struct sched_param* param)