1eeb69571SMatthew Dillon 
2eeb69571SMatthew Dillon #include "namespace.h"
3eeb69571SMatthew Dillon #include <machine/tls.h>
4eeb69571SMatthew Dillon #include <sys/mman.h>
5eeb69571SMatthew Dillon #include <sys/queue.h>
6eeb69571SMatthew Dillon #include <sys/stat.h>
7eeb69571SMatthew Dillon #include <sys/types.h>
8eeb69571SMatthew Dillon #include <errno.h>
9eeb69571SMatthew Dillon #include <fcntl.h>
10eeb69571SMatthew Dillon #include <limits.h>
11eeb69571SMatthew Dillon #include <pthread.h>
12eeb69571SMatthew Dillon #include <stdarg.h>
13eeb69571SMatthew Dillon #include <stdlib.h>
14eeb69571SMatthew Dillon #include <string.h>
15eeb69571SMatthew Dillon #include <time.h>
16eeb69571SMatthew Dillon #include <unistd.h>
17eeb69571SMatthew Dillon #ifdef _PTHREADS_DEBUGGING
18eeb69571SMatthew Dillon #include <stdio.h>
19eeb69571SMatthew Dillon #endif
20eeb69571SMatthew Dillon #include "un-namespace.h"
21eeb69571SMatthew Dillon 
22eeb69571SMatthew Dillon #include "thr_private.h"
23eeb69571SMatthew Dillon void
24eeb69571SMatthew Dillon _libthread_distribute_static_tls(size_t offset, void *src,
25eeb69571SMatthew Dillon 				 size_t len, size_t total_len);
26eeb69571SMatthew Dillon 
27eeb69571SMatthew Dillon void
_libthread_distribute_static_tls(size_t offset,void * src,size_t len,size_t total_len)28eeb69571SMatthew Dillon _libthread_distribute_static_tls(size_t offset, void *src,
29eeb69571SMatthew Dillon 				 size_t len, size_t total_len)
30eeb69571SMatthew Dillon {
31*940be950Szrj 	pthread_t curthread = tls_get_curthread();
32*940be950Szrj 	pthread_t td;
33eeb69571SMatthew Dillon 	char *tlsbase;
34eeb69571SMatthew Dillon 
35eeb69571SMatthew Dillon 	THREAD_LIST_LOCK(curthread);
36eeb69571SMatthew Dillon 	TAILQ_FOREACH(td, &_thread_list, tle) {
37eeb69571SMatthew Dillon 		tlsbase = (char *)td->tcb - offset;
38eeb69571SMatthew Dillon 		memcpy(tlsbase, src, len);
39eeb69571SMatthew Dillon 		memset(tlsbase + len, 0, total_len - len);
40eeb69571SMatthew Dillon 	}
41eeb69571SMatthew Dillon 	THREAD_LIST_UNLOCK(curthread);
42eeb69571SMatthew Dillon }
43eeb69571SMatthew Dillon 
44eeb69571SMatthew Dillon __strong_reference(_libthread_distribute_static_tls, _pthread_distribute_static_tls);
45