2 This file is part of the NoBug debugging library.
5 2007, 2008, 2009, 2010, Christian Thaeter <ct@pipapo.org>
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, contact Christian Thaeter <ct@pipapo.org>.
20 #define NOBUG_LIBNOBUG_C
26 Fake thread id's for non-threaded processes, only a single static one
28 static struct nobug_tls_data nothread_id
= {
33 .coverage_disable_cnt
= 0,
34 //struct llist_struct res_stack; /* resources of this thread */
37 struct nobug_tls_data
*
38 nobug_thread_set (const char* name
)
40 struct nobug_tls_data
* tls
= ¬hread_id
;
42 free ((char*)tls
->thread_id
);
46 snprintf (buf
, 256, "%s_%d", name
, tls
->thread_num
);
47 tls
->thread_id
= strdup(buf
);
50 nobug_log (&nobug_flag_nobug
, LOG_EMERG
, "NOBUG",
51 (const struct nobug_context
){"-", 0, "nobug_thread_set"},
52 " failed thread id allocation");
60 struct nobug_tls_data
*
61 nobug_thread_get (void)
63 struct nobug_tls_data
* tls
= ¬hread_id
;
65 return nobug_thread_set ("thread");
72 nobug_thread_id_set (const char* name
)
74 return nobug_thread_set (name
) -> thread_id
;
79 nobug_thread_id_get (void)
81 return nobug_thread_get () -> thread_id
;
86 nobug_thread_data (void)
88 return &nobug_thread_get () -> data
;