From 78d75b00afc8370df37409e0150a0649ce29c981 Mon Sep 17 00:00:00 2001 From: compudj Date: Thu, 26 Jan 2006 14:36:18 +0000 Subject: [PATCH] tls static init git-svn-id: http://ltt.polymtl.ca/svn@1493 04897980-b3bd-0310-b5e0-8ef037075253 --- usertrace/lttng_usertrace.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/usertrace/lttng_usertrace.c b/usertrace/lttng_usertrace.c index f989667f..7f1039f4 100644 --- a/usertrace/lttng_usertrace.c +++ b/usertrace/lttng_usertrace.c @@ -33,7 +33,6 @@ struct ltt_buf { }; struct lttng_trace_info { - struct lttng_trace_info *next; int active:1; struct { struct ltt_buf facilities; @@ -43,9 +42,28 @@ struct lttng_trace_info { /* TLS for the trace info */ -static __thread struct lttng_trace_info *test; -static __thread struct lttng_trace_info lttng_trace_info[MAX_TRACES]; +/* http://www.dis.com/gnu/gcc/C--98-Thread-Local-Edits.html + * + * Add after paragraph 4 + * + * The storage for an object of thread storage duration shall be statically + * initialized before the first statement of the thread startup function. An + * object of thread storage duration shall not require dynamic + * initialization. + * GCC extention permits init of a range. + */ +static __thread struct lttng_trace_info lttng_trace_info[MAX_TRACES] = +{ [ 0 ... MAX_TRACES-1 ].active = 0, + [ 0 ... MAX_TRACES-1 ].channel = + { NULL, + ATOMIC_INIT(0), + ATOMIC_INIT(0), + ATOMIC_INIT(0), + ATOMIC_INIT(0), + ATOMIC_INIT(0) + } +}; /* signal handler */ void __lttng_sig_trace_handler(int signo) -- 2.34.1