mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-27 06:48:31 +00:00
Make some small fixes to recent changes
This commit is contained in:
parent
c2590cf7a0
commit
179e048bba
5 changed files with 33 additions and 11 deletions
|
@ -16,7 +16,6 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/assert.h"
|
||||
#include "libc/intrin/atomic.h"
|
||||
#include "libc/intrin/kmalloc.h"
|
||||
#include "libc/stdio/internal.h"
|
||||
|
@ -27,13 +26,13 @@ static _Atomic(FILE *) __stdio_freelist;
|
|||
|
||||
FILE *__stdio_alloc(void) {
|
||||
FILE *f;
|
||||
f = atomic_load_explicit(&__stdio_freelist, memory_order_relaxed);
|
||||
f = atomic_load_explicit(&__stdio_freelist, memory_order_acquire);
|
||||
while (f) {
|
||||
if (atomic_compare_exchange_weak_explicit(
|
||||
&__stdio_freelist, &f,
|
||||
atomic_load_explicit(&f->next, memory_order_relaxed),
|
||||
memory_order_relaxed, memory_order_relaxed)) {
|
||||
atomic_store_explicit(&f->next, 0, memory_order_relaxed);
|
||||
atomic_load_explicit(&f->next, memory_order_acquire),
|
||||
memory_order_release, memory_order_relaxed)) {
|
||||
atomic_store_explicit(&f->next, 0, memory_order_release);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -48,13 +47,12 @@ FILE *__stdio_alloc(void) {
|
|||
|
||||
void __stdio_free(FILE *f) {
|
||||
FILE *g;
|
||||
_unassert(!atomic_load_explicit(&f->next, memory_order_relaxed));
|
||||
bzero(f, sizeof(*f));
|
||||
g = atomic_load_explicit(&__stdio_freelist, memory_order_relaxed);
|
||||
g = atomic_load_explicit(&__stdio_freelist, memory_order_acquire);
|
||||
for (;;) {
|
||||
atomic_store_explicit(&f->next, g, memory_order_relaxed);
|
||||
atomic_store_explicit(&f->next, g, memory_order_release);
|
||||
if (atomic_compare_exchange_weak_explicit(&__stdio_freelist, &g, f,
|
||||
memory_order_relaxed,
|
||||
memory_order_release,
|
||||
memory_order_relaxed)) {
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
╚────────────────────────────────────────────────────────────────'>/dev/null #*/
|
||||
dir=libc/sysv/calls
|
||||
. libc/sysv/gen.sh
|
||||
#include "libc/calls/syscall-sysv.internal.h"
|
||||
|
||||
# The Fifth Bell System Interface, Community Edition ┌─────────────────────────┐
|
||||
# » so many numbers │ legend │
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
*/
|
||||
void _wait0(const atomic_int *ctid) {
|
||||
int x;
|
||||
while ((x = atomic_load_explicit(ctid, memory_order_relaxed))) {
|
||||
while ((x = atomic_load_explicit(ctid, memory_order_acquire))) {
|
||||
nsync_futex_wait_(ctid, x, !IsWindows(), 0);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue