Skip to content

Commit

Permalink
LibPThread: Make pthread_exit a noreturn function
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
tryfinally authored and awesomekling committed Jul 20, 2020
1 parent 19d6884 commit f2d3cc7
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
1 change: 1 addition & 0 deletions Libraries/LibPthread/pthread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion Libraries/LibPthread/pthread.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions Libraries/LibThread/Thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit f2d3cc7

Please sign in to comment.