mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-15 15:20:02 +00:00
Make more fixups and quality assurance
This commit is contained in:
parent
85c58be942
commit
dcf9596620
17 changed files with 80 additions and 78 deletions
4
third_party/nsync/README.cosmo
vendored
4
third_party/nsync/README.cosmo
vendored
|
@ -33,10 +33,6 @@ LOCAL CHANGES
|
|||
lets us use weak cas when appropriate. It also avoids a superfluous
|
||||
relaxed load on failure. This mostly impacts aarch64, not x86_64.
|
||||
|
||||
- Modified *NSYNC to allocate waiter objects on the stack. We need it
|
||||
because we use *NSYNC mutexes to implement POSIX mutexes, which are
|
||||
too low-level to safely depend on malloc, or even mmap in our case.
|
||||
|
||||
- Rewrote most of the semaphore and futex system call support code so
|
||||
it works well with Cosmopolitan's fat runtime portability. *NSYNC's
|
||||
unit test suite passes on all supported platforms. However the BSDs
|
||||
|
|
12
third_party/nsync/mu.c
vendored
12
third_party/nsync/mu.c
vendored
|
@ -477,9 +477,9 @@ void nsync_mu_unlock (nsync_mu *mu) {
|
|||
and deallocate the mutex before the current thread touched the mutex
|
||||
word again. */
|
||||
uint32_t old_word = MU_WLOCK;
|
||||
if (!atomic_compare_exchange_weak_explicit (&mu->word, &old_word, 0,
|
||||
memory_order_release,
|
||||
memory_order_relaxed)) {
|
||||
if (!atomic_compare_exchange_strong_explicit (&mu->word, &old_word, 0,
|
||||
memory_order_release,
|
||||
memory_order_relaxed)) {
|
||||
/* Clear MU_ALL_FALSE because the critical section we're just
|
||||
leaving may have made some conditions true. */
|
||||
uint32_t new_word = (old_word - MU_WLOCK) & ~MU_ALL_FALSE;
|
||||
|
@ -508,9 +508,9 @@ void nsync_mu_runlock (nsync_mu *mu) {
|
|||
IGNORE_RACES_START ();
|
||||
/* See comment in nsync_mu_unlock(). */
|
||||
uint32_t old_word = MU_RLOCK;
|
||||
if (!atomic_compare_exchange_weak_explicit (&mu->word, &old_word, 0,
|
||||
memory_order_release,
|
||||
memory_order_relaxed)) {
|
||||
if (!atomic_compare_exchange_strong_explicit (&mu->word, &old_word, 0,
|
||||
memory_order_release,
|
||||
memory_order_relaxed)) {
|
||||
/* Sanity check: mutex must not be held in write mode and
|
||||
reader count must not be 0. */
|
||||
if (((old_word ^ MU_WLOCK) & (MU_WLOCK | MU_RLOCK_FIELD)) == 0) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue