1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 05:07:35 +00:00

LibPthread: Return errors as positive return values

pthread implementations generally return errors as a positive non-zero
value. Our kernel generally returns errors as negative values. If we
receive a negative value from a system call, turn it into a positive
return value to relay the error appropriately.

Also, fix the tt test utility to not rely on errno, as the pthread
library does not use errno.
This commit is contained in:
Tom 2020-12-08 15:51:39 -07:00 committed by Andreas Kling
parent da5cc34ebb
commit bcb9363a97
2 changed files with 22 additions and 17 deletions

View file

@ -162,19 +162,18 @@ int detached_test()
return nullptr;
},
nullptr);
if (rc < 0) {
perror("pthread_create");
if (rc != 0) {
printf("pthread_create: %s\n", strerror(rc));
return 4;
}
void* ret_val;
errno = 0;
rc = pthread_join(thread_id, &ret_val);
if (rc < 0 && errno != EINVAL) {
perror("pthread_join");
if (rc != 0 && rc != EINVAL) {
printf("pthread_join: %s\n", strerror(rc));
return 5;
}
if (errno != EINVAL) {
if (rc != EINVAL) {
printf("Expected EINVAL! Thread was joinable?\n");
return 6;
}