3 #include <mach/cthreads.h>
14 PyThread__init_thread(void)
16 #ifndef HURD_C_THREADS
17 /* Roland McGrath said this should not be used since this is
18 done while linking to threads */
30 PyThread_start_new_thread(void (*func
)(void *), void *arg
)
32 int success
= 0; /* init not needed when SOLARIS_THREADS and */
33 /* C_THREADS implemented properly */
35 dprintf(("PyThread_start_new_thread called\n"));
37 PyThread_init_thread();
38 /* looks like solaris detaches the thread to never rejoin
41 cthread_detach(cthread_fork((cthread_fn_t
) func
, arg
));
42 return success
< 0 ? -1 : 0;
46 PyThread_get_thread_ident(void)
49 PyThread_init_thread();
50 return (long) cthread_self();
54 PyThread_exit_thread(void)
56 dprintf(("PyThread_exit_thread called\n"));
66 PyThread_allocate_lock(void)
70 dprintf(("PyThread_allocate_lock called\n"));
72 PyThread_init_thread();
75 if (mutex_init(lock
)) {
80 dprintf(("PyThread_allocate_lock() -> %p\n", lock
));
81 return (PyThread_type_lock
) lock
;
85 PyThread_free_lock(PyThread_type_lock lock
)
87 dprintf(("PyThread_free_lock(%p) called\n", lock
));
92 PyThread_acquire_lock(PyThread_type_lock lock
, int waitflag
)
96 dprintf(("PyThread_acquire_lock(%p, %d) called\n", lock
, waitflag
));
97 if (waitflag
) { /* blocking */
98 mutex_lock((mutex_t
)lock
);
100 } else { /* non blocking */
101 success
= mutex_try_lock((mutex_t
)lock
);
103 dprintf(("PyThread_acquire_lock(%p, %d) -> %d\n", lock
, waitflag
, success
));
108 PyThread_release_lock(PyThread_type_lock lock
)
110 dprintf(("PyThread_release_lock(%p) called\n", lock
));
111 mutex_unlock((mutex_t
)lock
);