1 #include <limits.h> 2 #include <stdlib.h> 3 #include <klibc/compiler.h> 4 #include "thread.h" 5 #include "core.h" 6 7 __noreturn __exit_thread(void) 8 { 9 struct thread *curr = current(); 10 11 cli(); 12 13 /* Remove from the linked list */ 14 curr->list.prev->next = curr->list.next; 15 curr->list.next->prev = curr->list.prev; 16 17 /* Free allocated stacks (note: free(NULL) is permitted and safe). */ 18 free(curr->stack); 19 free(curr->rmstack); 20 21 /* 22 * Note: __schedule() can explictly handle the case where 23 * curr isn't part of the linked list anymore, as long as 24 * curr->list.next is still valid. 25 */ 26 __schedule(); 27 28 /* We should never get here */ 29 kaboom(); 30 } 31