summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMuhammad Zahalqa <m@tryfinally.com>2020-07-18 22:35:12 +0300
committerAndreas Kling <kling@serenityos.org>2020-07-21 01:10:41 +0200
commitf2d3cc7325c6c75b7ceff55c030c22ac89e3ce4d (patch)
treefc644e3b31aa0eb34a4b5eb19f4db3ba0bf09967
parent19d6884529db681bc917f7f3d0a5cee496a76a0e (diff)
downloadserenity-f2d3cc7325c6c75b7ceff55c030c22ac89e3ce4d.zip
LibPThread: Make pthread_exit a noreturn function
LibPThread: mark pthread_exit a noreturn function using compiler attributes LibThread: remove a call to pthread_exit from Thread::start lambda expression as it make the return of teh lambda unreachable.
-rw-r--r--Libraries/LibPthread/pthread.cpp1
-rw-r--r--Libraries/LibPthread/pthread.h2
-rw-r--r--Libraries/LibThread/Thread.cpp3
3 files changed, 3 insertions, 3 deletions
diff --git a/Libraries/LibPthread/pthread.cpp b/Libraries/LibPthread/pthread.cpp
index e90e8a7399..f3a17849b6 100644
--- a/Libraries/LibPthread/pthread.cpp
+++ b/Libraries/LibPthread/pthread.cpp
@@ -83,6 +83,7 @@ static int create_thread(void* (*entry)(void*), void* argument, PthreadAttrImpl*
return syscall(SC_create_thread, pthread_create_helper, thread_params);
}
+[[noreturn]]
static void exit_thread(void* code)
{
syscall(SC_exit_thread, code);
diff --git a/Libraries/LibPthread/pthread.h b/Libraries/LibPthread/pthread.h
index 6fbb7453bb..1f71b911b8 100644
--- a/Libraries/LibPthread/pthread.h
+++ b/Libraries/LibPthread/pthread.h
@@ -35,7 +35,7 @@
__BEGIN_DECLS
int pthread_create(pthread_t*, pthread_attr_t*, void* (*)(void*), void*);
-void pthread_exit(void*);
+void pthread_exit(void*) __attribute__ ((noreturn));
int pthread_kill(pthread_t, int);
void pthread_cleanup_push(void (*)(void*), void*);
void pthread_cleanup_pop(int);
diff --git a/Libraries/LibThread/Thread.cpp b/Libraries/LibThread/Thread.cpp
index 94b5bcd502..7828627d30 100644
--- a/Libraries/LibThread/Thread.cpp
+++ b/Libraries/LibThread/Thread.cpp
@@ -51,8 +51,7 @@ void LibThread::Thread::start()
[](void* arg) -> void* {
Thread* self = static_cast<Thread*>(arg);
size_t exit_code = self->m_action();
- self->m_tid = 0;
- pthread_exit((void*)exit_code);
+ self->m_tid = 0;
return (void*)exit_code;
},
static_cast<void*>(this));