]> git.saurik.com Git - apple/libpthread.git/blob - kern/kern_init.c
1f7e547d6f23306e758fe86087c59467ceb9daf4
[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 .fill_procworkqueue = _fill_procworkqueue,
21 .workqueue_init_lock = _workqueue_init_lock,
22 .workqueue_destroy_lock = _workqueue_destroy_lock,
23 .workqueue_exit = _workqueue_exit,
24 .workqueue_mark_exiting = _workqueue_mark_exiting,
25 .workqueue_thread_yielded = _workqueue_thread_yielded,
26 .workqueue_get_sched_callback = _workqueue_get_sched_callback,
27 .pth_proc_hashinit = _pth_proc_hashinit,
28 .pth_proc_hashdelete = _pth_proc_hashdelete,
29 .bsdthread_create = _bsdthread_create,
30 .bsdthread_register = _bsdthread_register,
31 .bsdthread_terminate = _bsdthread_terminate,
32 .bsdthread_ctl = _bsdthread_ctl,
33 .thread_selfid = _thread_selfid,
34 .workq_kernreturn = _workq_kernreturn,
35 .workq_open = _workq_open,
36
37 .psynch_mutexwait = _psynch_mutexwait,
38 .psynch_mutexdrop = _psynch_mutexdrop,
39 .psynch_cvbroad = _psynch_cvbroad,
40 .psynch_cvsignal = _psynch_cvsignal,
41 .psynch_cvwait = _psynch_cvwait,
42 .psynch_cvclrprepost = _psynch_cvclrprepost,
43 .psynch_rw_longrdlock = _psynch_rw_longrdlock,
44 .psynch_rw_rdlock = _psynch_rw_rdlock,
45 .psynch_rw_unlock = _psynch_rw_unlock,
46 .psynch_rw_wrlock = _psynch_rw_wrlock,
47 .psynch_rw_yieldwrlock = _psynch_rw_yieldwrlock,
48
49 .workq_reqthreads = _workq_reqthreads,
50 .thread_qos_from_pthread_priority = _thread_qos_from_pthread_priority,
51 };
52
53 kern_return_t pthread_start(__unused kmod_info_t * ki, __unused void *d)
54 {
55 pthread_kext_register((pthread_functions_t)&pthread_internal_functions, &pthread_kern);
56 return KERN_SUCCESS;
57 }
58
59 kern_return_t pthread_stop(__unused kmod_info_t *ki, __unused void *d)
60 {
61 return KERN_FAILURE;
62 }
63
64 struct uthread*
65 current_uthread(void)
66 {
67 thread_t th = current_thread();
68 return pthread_kern->get_bsdthread_info(th);
69 }