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