5 //  Created by Matt Wright on 9/13/12. 
   6 //  Copyright (c) 2012 Matt Wright. All rights reserved. 
   9 #include <kern/thread.h> 
  10 #include <kern/debug.h> 
  11 #include "kern_internal.h" 
  13 kern_return_t 
pthread_start(kmod_info_t 
* ki
, void *d
); 
  14 kern_return_t 
pthread_stop(kmod_info_t 
*ki
, void *d
); 
  16 pthread_callbacks_t pthread_kern
; 
  18 const struct pthread_functions_s pthread_internal_functions 
= { 
  19         .pthread_init 
= _pthread_init
, 
  20         .pth_proc_hashinit 
= _pth_proc_hashinit
, 
  21         .pth_proc_hashdelete 
= _pth_proc_hashdelete
, 
  22         .bsdthread_create 
= _bsdthread_create
, 
  23         .bsdthread_register 
= _bsdthread_register
, 
  24         .bsdthread_terminate 
= _bsdthread_terminate
, 
  25         .thread_selfid 
= _thread_selfid
, 
  27         .psynch_mutexwait 
= _psynch_mutexwait
, 
  28         .psynch_mutexdrop 
= _psynch_mutexdrop
, 
  29         .psynch_cvbroad 
= _psynch_cvbroad
, 
  30         .psynch_cvsignal 
= _psynch_cvsignal
, 
  31         .psynch_cvwait 
= _psynch_cvwait
, 
  32         .psynch_cvclrprepost 
= _psynch_cvclrprepost
, 
  33         .psynch_rw_longrdlock 
= _psynch_rw_longrdlock
, 
  34         .psynch_rw_rdlock 
= _psynch_rw_rdlock
, 
  35         .psynch_rw_unlock 
= _psynch_rw_unlock
, 
  36         .psynch_rw_wrlock 
= _psynch_rw_wrlock
, 
  37         .psynch_rw_yieldwrlock 
= _psynch_rw_yieldwrlock
, 
  39         .pthread_find_owner 
= _pthread_find_owner
, 
  40         .pthread_get_thread_kwq 
= _pthread_get_thread_kwq
, 
  42         .workq_create_threadstack 
= workq_create_threadstack
, 
  43         .workq_destroy_threadstack 
= workq_destroy_threadstack
, 
  44         .workq_setup_thread 
= workq_setup_thread
, 
  45         .workq_handle_stack_events 
= workq_handle_stack_events
, 
  46         .workq_markfree_threadstack 
= workq_markfree_threadstack
, 
  49 kern_return_t 
pthread_start(__unused kmod_info_t 
* ki
, __unused 
void *d
) 
  51         pthread_kext_register((pthread_functions_t
)&pthread_internal_functions
, &pthread_kern
); 
  55 kern_return_t 
pthread_stop(__unused kmod_info_t 
*ki
, __unused 
void *d
) 
  63         thread_t th 
= current_thread(); 
  64         return pthread_kern
->get_bsdthread_info(th
);