From 171ef826e1489031bc48745f29fa2d4657bf165f Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Thu, 28 Mar 2019 10:49:05 +0100 Subject: make all library-internal static buffers thread-local We have a number of library-internal static global buffers which are mainly used for various stringification functions. This worked as all of the related Osmocom programs were strictly single-threaded. Let's make those buffers at least thread-local. This way every thread gets their own set of buffers, and it's safe for multiple threads to execute the same functions once. They're of course still not re-entrant. If you need re-entrancy, you will need to use the _c() or _buf() suffix version of those functions and work with your own (stack or heap) buffers. Change-Id: I50eb2436a7c1261d79a9d2955584dce92780ca07 --- src/sim/core.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/sim') diff --git a/src/sim/core.c b/src/sim/core.c index 63b3000b..b93633c1 100644 --- a/src/sim/core.c +++ b/src/sim/core.c @@ -300,8 +300,7 @@ ret_def: char *osim_print_sw(const struct osim_card_hdl *ch, uint16_t sw_in) { - /* FIXME: do we want to mark this as __thread? */ - static char sw_print_buf[256]; + static __thread char sw_print_buf[256]; return osim_print_sw_buf(sw_print_buf, sizeof(sw_print_buf), ch, sw_in); } -- cgit v1.2.3