mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-20 17:40:30 +00:00
Get rid of kmalloc()
This changes *NSYNC to allocate waiters on the stack so our locks don't need to depend on dynamic memory. This make our runtiem simpler, and it also fixes bugs with thread cancellation support.
This commit is contained in:
parent
77a7873057
commit
a359de7893
57 changed files with 405 additions and 472 deletions
10
third_party/nsync/mu_semaphore_gcd.c
vendored
10
third_party/nsync/mu_semaphore_gcd.c
vendored
|
@ -41,6 +41,11 @@ static dispatch_semaphore_t dispatch_semaphore_create(long count) {
|
|||
return (ds);
|
||||
}
|
||||
|
||||
static void dispatch_release (dispatch_semaphore_t ds) {
|
||||
__syslib->dispatch_release (ds);
|
||||
STRACE ("dispatch_release(%#lx)", ds);
|
||||
}
|
||||
|
||||
static long dispatch_semaphore_wait (dispatch_semaphore_t ds,
|
||||
dispatch_time_t dt) {
|
||||
long rc = __syslib->dispatch_semaphore_wait (ds, dt);
|
||||
|
@ -65,6 +70,11 @@ void nsync_mu_semaphore_init_gcd (nsync_semaphore *s) {
|
|||
*(dispatch_semaphore_t *)s = dispatch_semaphore_create (0);
|
||||
}
|
||||
|
||||
/* Releases system resources associated with *s. */
|
||||
void nsync_mu_semaphore_destroy_gcd (nsync_semaphore *s) {
|
||||
dispatch_release (*(dispatch_semaphore_t *)s);
|
||||
}
|
||||
|
||||
/* Wait until the count of *s exceeds 0, and decrement it. */
|
||||
errno_t nsync_mu_semaphore_p_gcd (nsync_semaphore *s) {
|
||||
dispatch_semaphore_wait (*(dispatch_semaphore_t *)s,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue