mailing list of musl libc
 help / color / mirror / code / Atom feed
87158a7afa7e1b900fd5a75fc93369be6fe624e1 blob 1312 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 struct pthread *main_thread = &(struct pthread){0};

/* pthread_key_create.c overrides this with a modifiable array
   whenever the executable is linked with pthread_key_create. If it is
   not, and an attempt is made to write to the pthread_key system, the
   program will crash, since this is in a read-only segment. */
WEAK_PROVIDE_DUMMY;
_Readonly_alias void* __pthread_tsd_main[PTHREAD_KEYS_MAX];

static int init_main_thread()
{
	__syscall(SYS_rt_sigprocmask, SIG_UNBLOCK,
		SIGPT_SET, 0, __SYSCALL_SSLEN);
	if (__set_thread_area(TP_ADJ(main_thread)) < 0) return -1;
	main_thread->canceldisable = libc.canceldisable;
	main_thread->tsd = __pthread_tsd_main;
	main_thread->errno_ptr = __errno_location();
	main_thread->self = main_thread;
	main_thread->tid = main_thread->pid =
		__syscall(SYS_set_tid_address, &main_thread->tid);
	libc.main_thread = main_thread;
	return 0;
}

pthread_t __pthread_self_def()
{
	static int init, failed;
	if (!init) {
		if (failed) return 0;
		if (init_main_thread() < 0) failed = 1;
		if (failed) return 0;
		init = 1;
	}
	return __pthread_self();
}

weak_alias(__pthread_self_def, pthread_self);
weak_alias(__pthread_self_def, __pthread_self_init);

void *__install_initial_tls(void *p)
{
	main_thread = p;
	return __pthread_self_def();
}
debug log:

solving 87158a7 ...
found 87158a7 in https://inbox.vuxu.org/musl/af173b4d4be85eb3e4b10cf946385016cba6f5f4.1360968989.git.Jens.Gustedt@inria.fr/
found 23dbaa5 in https://git.vuxu.org/mirror/musl/
preparing index
index prepared:
100644 23dbaa5eb805ccbcf65d9e1772b9ab6cabb52853	src/thread/pthread_self.c

applying [1/1] https://inbox.vuxu.org/musl/af173b4d4be85eb3e4b10cf946385016cba6f5f4.1360968989.git.Jens.Gustedt@inria.fr/
diff --git a/src/thread/pthread_self.c b/src/thread/pthread_self.c
index 23dbaa5..87158a7 100644

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

index at:
100644 87158a7afa7e1b900fd5a75fc93369be6fe624e1	src/thread/pthread_self.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).