mailing list of musl libc
 help / color / mirror / code / Atom feed
e67f0f3cfaebc6f3d660f20f0c208833b5cf6ea1 blob 574 bytes (raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
 
#include "pthread_impl.h"

void __lock(volatile int *addr)
{
	if (libc.threads_minus_1) {
		int volatile* waiters = addr+1;
		for (;;) {
			for (int spins = 0; spins < 10000; ++spins) {
				if (a_tas(addr)) a_spin();
				else {
					/* a lock must ensure that all data
					   that is written before will be
					   visible */
					a_aqf();
					return;
				}
			}
			a_inc(waiters);
			__syscall(SYS_futex, addr, FUTEX_WAIT|THRD_PRIVATE, 1, 0);
			a_dec(waiters);
		}
	}
}

void __unlock(volatile int *l)
{
	a_spunl(l);
	if (l[1]) __wake_priv(l, 1);
}
debug log:

solving 8a42e2d ...
found 8a42e2d in https://inbox.vuxu.org/musl/1408049748.4951.134.camel@eris.loria.fr/
found 0874c04 in https://git.vuxu.org/mirror/musl/
preparing index
index prepared:
100644 0874c04a4c0a81a9fa0dc032479ec18cec81d8aa	src/thread/__lock.c

applying [1/1] https://inbox.vuxu.org/musl/1408049748.4951.134.camel@eris.loria.fr/
diff --git a/src/thread/__lock.c b/src/thread/__lock.c\r
index 0874c04..8a42e2d 100644\r

Checking patch src/thread/__lock.c...
Applied patch src/thread/__lock.c cleanly.

index at:
100644 e67f0f3cfaebc6f3d660f20f0c208833b5cf6ea1	src/thread/__lock.c

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).