]> git.saurik.com Git - apple/libpthread.git/blob - kern/kern_init.c
libpthread-416.60.2.tar.gz
[apple/libpthread.git] / kern / kern_init.c
1 //
2 // pthread.c
3 // pthread
4 //
5 // Created by Matt Wright on 9/13/12.
6 // Copyright (c) 2012 Matt Wright. All rights reserved.
7 //
8
9 #include <kern/thread.h>
10 #include <kern/debug.h>
11 #include "kern_internal.h"
12
13 kern_return_t pthread_start(kmod_info_t * ki, void *d);
14 kern_return_t pthread_stop(kmod_info_t *ki, void *d);
15
16 pthread_callbacks_t pthread_kern;
17
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,
26
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,
38
39 .pthread_find_owner = _pthread_find_owner,
40 .pthread_get_thread_kwq = _pthread_get_thread_kwq,
41
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,
47 };
48
49 kern_return_t pthread_start(__unused kmod_info_t * ki, __unused void *d)
50 {
51 pthread_kext_register((pthread_functions_t)&pthread_internal_functions, &pthread_kern);
52 return KERN_SUCCESS;
53 }
54
55 kern_return_t pthread_stop(__unused kmod_info_t *ki, __unused void *d)
56 {
57 return KERN_FAILURE;
58 }
59
60 struct uthread*
61 current_uthread(void)
62 {
63 thread_t th = current_thread();
64 return pthread_kern->get_bsdthread_info(th);
65 }