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
diff --git a/src/gb/gprs_ns.c b/src/gb/gprs_ns.c
index cee4885..c77ebb3 100644
--- a/src/gb/gprs_ns.c
+++ b/src/gb/gprs_ns.c
@@ -1552,7 +1552,7 @@
const char *gprs_ns_ll_str(const struct gprs_nsvc *nsvc)
{
- static char buf[80];
+ static __thread char buf[80];
return gprs_ns_ll_str_buf(buf, sizeof(buf), nsvc);
}