1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 13:18:13 +00:00

LibPthread: Fix incompatible pthread_setname_np(), pthread_getname_np()

Other implementations of pthread_setname_np() do not take the name
length as an argument.

For pthread_getname_np(), other implementations take the buffer size
as a size_t.

This patch brings us in line with other implementations.
This commit is contained in:
Andreas Kling 2020-01-11 12:54:30 +01:00
parent 24c736b0e7
commit eede6cfd06
3 changed files with 8 additions and 14 deletions

View file

@ -537,21 +537,15 @@ int pthread_setspecific(pthread_key_t key, const void* value)
t_specifics.values[key] = const_cast<void*>(value);
return 0;
}
int pthread_setname_np(pthread_t thread, const char* buffer, int buffer_size)
int pthread_setname_np(pthread_t thread, const char* name)
{
if (buffer_size < 0) {
errno = EINVAL;
return -1;
}
return syscall(SC_set_thread_name, thread, buffer, buffer_size);
if (!name)
return EFAULT;
return syscall(SC_set_thread_name, thread, name, strlen(name));
}
int pthread_getname_np(pthread_t thread, char* buffer, int buffer_size)
int pthread_getname_np(pthread_t thread, char* buffer, size_t buffer_size)
{
if (buffer_size < 0) {
errno = EINVAL;
return -1;
}
return syscall(SC_get_thread_name, thread, buffer, buffer_size);
}