diff --git a/libpthread/Makefile b/libpthread/Makefile
index d44926f2..7662e693 100644
--- a/libpthread/Makefile
+++ b/libpthread/Makefile
@@ -22,6 +22,7 @@ pthread_cond_signal.o \
pthread_cond_timedwait.o \
pthread_cond_wait.o \
pthread_equal.o \
+pthread_exit.o \
pthread_initialize.o \
pthread_mutexattr_destroy.o \
pthread_mutexattr_gettype.o \
diff --git a/libpthread/include/pthread.h b/libpthread/include/pthread.h
index fbd3f081..d0642748 100644
--- a/libpthread/include/pthread.h
+++ b/libpthread/include/pthread.h
@@ -209,7 +209,8 @@ int pthread_condattr_setclock(pthread_condattr_t*, clockid_t);
/* TODO: pthread_create */
/* TODO: pthread_detach */
int pthread_equal(pthread_t, pthread_t);
-/* TODO: pthread_exit */
+__attribute__((__noreturn__))
+void pthread_exit(void*);
/* TODO: pthread_getconcurrency */
/* TODO: pthread_getcpuclockid */
/* TODO: pthread_getschedparam */
diff --git a/libpthread/pthread_exit.c++ b/libpthread/pthread_exit.c++
new file mode 100644
index 00000000..c23d03ba
--- /dev/null
+++ b/libpthread/pthread_exit.c++
@@ -0,0 +1,46 @@
+/*******************************************************************************
+
+ Copyright(C) Jonas 'Sortie' Termansen 2013, 2014.
+
+ This file is part of Sortix libpthread.
+
+ Sortix libpthread is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published by the
+ Free Software Foundation, either version 3 of the License, or (at your
+ option) any later version.
+
+ Sortix libpthread is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with Sortix libpthread. If not, see .
+
+ pthread_exit.c++
+ Exits the current thread.
+
+*******************************************************************************/
+
+#include
+
+#include
+#include
+#include
+#include
+
+extern "C"
+__attribute__((__noreturn__))
+void pthread_exit(void* /*return_value*/)
+{
+ struct pthread* thread = pthread_self();
+ size_t num_threads = 1;
+ if ( num_threads == 1 )
+ exit(0);
+ struct exit_thread extended;
+ memset(&extended, 0, sizeof(extended));
+ extended.unmap_from = thread->uthread.stack_mmap;
+ extended.unmap_size = thread->uthread.stack_size;
+ exit_thread(0, EXIT_THREAD_UNMAP, &extended);
+ __builtin_unreachable();
+}