2 #include <mach/cthreads.h>
9 PyThread__init_thread(void)
18 PyThread_start_new_thread(void (*func
)(void *), void *arg
)
20 int success
= 0; /* init not needed when SOLARIS_THREADS and */
21 /* C_THREADS implemented properly */
23 dprintf(("PyThread_start_new_thread called\n"));
25 PyThread_init_thread();
26 /* looks like solaris detaches the thread to never rejoin
29 cthread_detach(cthread_fork((cthread_fn_t
) func
, arg
));
30 return success
< 0 ? 0 : 1;
34 PyThread_get_thread_ident(void)
37 PyThread_init_thread();
38 return (long) cthread_self();
42 do_PyThread_exit_thread(int no_cleanup
)
44 dprintf(("PyThread_exit_thread called\n"));
54 PyThread_exit_thread(void)
56 do_PyThread_exit_thread(0);
60 PyThread__exit_thread(void)
62 do_PyThread_exit_thread(1);
67 void do_PyThread_exit_prog(int status
, int no_cleanup
)
69 dprintf(("PyThread_exit_prog(%d) called\n", status
));
82 PyThread_exit_prog(int status
)
84 do_PyThread_exit_prog(status
, 0);
88 PyThread__exit_prog(int status
)
90 do_PyThread_exit_prog(status
, 1);
92 #endif /* NO_EXIT_PROG */
98 PyThread_allocate_lock(void)
102 dprintf(("PyThread_allocate_lock called\n"));
104 PyThread_init_thread();
106 lock
= mutex_alloc();
107 if (mutex_init(lock
)) {
108 perror("mutex_init");
112 dprintf(("PyThread_allocate_lock() -> %p\n", lock
));
113 return (PyThread_type_lock
) lock
;
117 PyThread_free_lock(PyThread_type_lock lock
)
119 dprintf(("PyThread_free_lock(%p) called\n", lock
));
124 PyThread_acquire_lock(PyThread_type_lock lock
, int waitflag
)
128 dprintf(("PyThread_acquire_lock(%p, %d) called\n", lock
, waitflag
));
129 if (waitflag
) { /* blocking */
132 } else { /* non blocking */
133 success
= mutex_try_lock(lock
);
135 dprintf(("PyThread_acquire_lock(%p, %d) -> %d\n", lock
, waitflag
, success
));
140 PyThread_release_lock(PyThread_type_lock lock
)
142 dprintf(("PyThread_release_lock(%p) called\n", lock
));
143 mutex_unlock((mutex_t
)lock
);
149 * This implementation is ripped directly from the pthreads implementation.
150 * Which is to say that it is 100% non-functional at this time.
152 * Assuming the page is still up, documentation can be found at:
154 * http://www.doc.ic.ac.uk/~mac/manuals/solaris-manual-pages/solaris/usr/man/man2/_lwp_sema_wait.2.html
156 * Looking at the man page, it seems that one could easily implement a
157 * semaphore using a condition.
161 PyThread_allocate_sema(int value
)
164 dprintf(("PyThread_allocate_sema called\n"));
166 PyThread_init_thread();
168 dprintf(("PyThread_allocate_sema() -> %p\n", sema
));
169 return (PyThread_type_sema
) sema
;
173 PyThread_free_sema(PyThread_type_sema sema
)
175 dprintf(("PyThread_free_sema(%p) called\n", sema
));
179 PyThread_down_sema(PyThread_type_sema sema
, int waitflag
)
181 dprintf(("PyThread_down_sema(%p, %d) called\n", sema
, waitflag
));
182 dprintf(("PyThread_down_sema(%p) return\n", sema
));
187 PyThread_up_sema(PyThread_type_sema sema
)
189 dprintf(("PyThread_up_sema(%p)\n", sema
));