aboutsummaryrefslogtreecommitdiff
path: root/benchmarks/common/syscalls.c
diff options
context:
space:
mode:
authorAndrew Waterman <waterman@cs.berkeley.edu>2014-12-13 03:53:49 -0800
committerAndrew Waterman <waterman@cs.berkeley.edu>2014-12-13 03:54:07 -0800
commit74c924f975b966f4c7b67bae135548dc837ae299 (patch)
treef3681ef6eba0e1d6bab12d004fbe81b6b61b1901 /benchmarks/common/syscalls.c
parent984abbe6e67503c93dbb13d9a305960f11c4ba7b (diff)
downloadriscv-tests-74c924f975b966f4c7b67bae135548dc837ae299.zip
riscv-tests-74c924f975b966f4c7b67bae135548dc837ae299.tar.gz
riscv-tests-74c924f975b966f4c7b67bae135548dc837ae299.tar.bz2
Initialize static TLS for the benchmarks
Diffstat (limited to 'benchmarks/common/syscalls.c')
-rw-r--r--benchmarks/common/syscalls.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/benchmarks/common/syscalls.c b/benchmarks/common/syscalls.c
index ddbb795..1e4efab 100644
--- a/benchmarks/common/syscalls.c
+++ b/benchmarks/common/syscalls.c
@@ -125,8 +125,20 @@ int __attribute__((weak)) main(int argc, char** argv)
return -1;
}
+static void init_tls()
+{
+ register void* thread_pointer asm("tp");
+ extern char _tls_data;
+ extern __thread char _tdata_begin, _tdata_end, _tbss_end;
+ size_t tdata_size = &_tdata_end - &_tdata_begin;
+ memcpy(thread_pointer, &_tls_data, tdata_size);
+ size_t tbss_size = &_tbss_end - &_tdata_end;
+ memset(thread_pointer + tdata_size, 0, tbss_size);
+}
+
void _init(int cid, int nc)
{
+ init_tls();
thread_entry(cid, nc);
// only single-threaded programs should ever get here.