mailing list of musl libc
 help / color / mirror / code / Atom feed
084cbaa30764da5cf30394c36af3097f56fccb58 blob 878 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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
 
#include "pthread_impl.h"

static void (*keys[PTHREAD_KEYS_MAX])(void *);

static void nodtor(void *dummy)
{
}

int pthread_key_create(pthread_key_t *k, void (*dtor)(void *))
{
	unsigned i = (uintptr_t)&k / 16 % PTHREAD_KEYS_MAX;
	unsigned j = i;

	__pthread_self_init();
	if (!dtor) dtor = nodtor;
	do {
		if (!a_cas_p(keys+j, 0, dtor)) {
			*k = j;
			return 0;
		}
	} while ((j=(j+1)%PTHREAD_KEYS_MAX) != i);
	return EAGAIN;
}

int pthread_key_delete(pthread_key_t k)
{
	keys[k] = 0;
	return 0;
}

void __pthread_tsd_run_dtors()
{
	pthread_t self = __pthread_self();
	int i, j, not_finished = self->tsd_used;
	for (j=0; not_finished && j<PTHREAD_DESTRUCTOR_ITERATIONS; j++) {
		not_finished = 0;
		for (i=0; i<PTHREAD_KEYS_MAX; i++) {
			if (self->tsd[i] && keys[i]) {
				void *tmp = self->tsd[i];
				self->tsd[i] = 0;
				keys[i](tmp);
				not_finished = 1;
			}
		}
	}
}
debug log:

solving 084cbaa ...
found 084cbaa in https://inbox.vuxu.org/musl/1360579429.9132.37.camel@eris.loria.fr/ ||
	https://inbox.vuxu.org/musl/1360574285.9132.14.camel@eris.loria.fr/
found e51cb02 in https://git.vuxu.org/mirror/musl/
preparing index
index prepared:
100644 e51cb02325d4908a8ac91b58d6b6afde47a5af6d	src/thread/pthread_key_create.c

applying [1/2] https://inbox.vuxu.org/musl/1360579429.9132.37.camel@eris.loria.fr/
diff --git a/src/thread/pthread_key_create.c b/src/thread/pthread_key_create.c
index e51cb02..084cbaa 100644

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

skipping https://inbox.vuxu.org/musl/1360574285.9132.14.camel@eris.loria.fr/ for 084cbaa
index at:
100644 084cbaa30764da5cf30394c36af3097f56fccb58	src/thread/pthread_key_create.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).