diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-12-07 14:33:18 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-12-07 14:52:27 +0100 |
commit | eaab7f567216891fa0eb8b1960888b603d5f973b (patch) | |
tree | f81dc1a5c9d3013891fd30ba1dd6ef6bdb355862 | |
parent | babb72621221572f6cf2ae3a1171e924b7bb12f1 (diff) | |
download | serenity-eaab7f567216891fa0eb8b1960888b603d5f973b.zip |
LibPthread: Don't set errno in pthread functions
POSIX says that pthread API's don't set errno directly. If there is an
error, it should be the return value from the function instead.
-rw-r--r-- | Libraries/LibPthread/pthread.cpp | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/Libraries/LibPthread/pthread.cpp b/Libraries/LibPthread/pthread.cpp index 8c35406dc1..6e43fe1281 100644 --- a/Libraries/LibPthread/pthread.cpp +++ b/Libraries/LibPthread/pthread.cpp @@ -24,8 +24,7 @@ extern "C" { static int create_thread(void* (*entry)(void*), void* argument, void* stack) { - int rc = syscall(SC_create_thread, entry, argument, stack); - __RETURN_WITH_ERRNO(rc, rc, -1); + return syscall(SC_create_thread, entry, argument, stack); } static void exit_thread(void* code) @@ -83,8 +82,7 @@ void pthread_exit(void* value_ptr) int pthread_join(pthread_t thread, void** exit_value_ptr) { - int rc = syscall(SC_join_thread, thread, exit_value_ptr); - __RETURN_WITH_ERRNO(rc, rc, -1); + return syscall(SC_join_thread, thread, exit_value_ptr); } int pthread_mutex_init(pthread_mutex_t* mutex, const pthread_mutexattr_t* attributes) @@ -413,10 +411,9 @@ int pthread_cond_timedwait(pthread_cond_t* cond, pthread_mutex_t* mutex, const s while (node.waiting) { struct timespec now; if (clock_gettime(condvar.clock, &now) < 0) - return -1; + return errno; if ((abstime->tv_sec < now.tv_sec) || (abstime->tv_sec == now.tv_sec && abstime->tv_nsec <= now.tv_nsec)) { - errno = ETIMEDOUT; - return -1; + return ETIMEDOUT; } pthread_mutex_unlock(mutex); sched_yield(); |