aboutsummaryrefslogtreecommitdiffstats
path: root/src/gsm/gsm48.c
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2019-03-28 10:49:05 +0100
committerHarald Welte <laforge@gnumonks.org>2019-06-04 10:47:30 +0200
commit171ef826e1489031bc48745f29fa2d4657bf165f (patch)
tree08c8c32fae7f33f59df7621d6e3e8b8e127d856b /src/gsm/gsm48.c
parent9b207419105c5e07504b1b7bf380eda07c127bb2 (diff)
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
Diffstat (limited to 'src/gsm/gsm48.c')
-rw-r--r--src/gsm/gsm48.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/gsm/gsm48.c b/src/gsm/gsm48.c
index c2c19cfe..c97337b6 100644
--- a/src/gsm/gsm48.c
+++ b/src/gsm/gsm48.c
@@ -203,7 +203,7 @@ char *osmo_rai_name_buf(char *buf, size_t buf_len, const struct gprs_ra_id *rai)
*/
const char *osmo_rai_name(const struct gprs_ra_id *rai)
{
- static char buf[32];
+ static __thread char buf[32];
return osmo_rai_name_buf(buf, sizeof(buf), rai);
}
@@ -502,7 +502,7 @@ char *osmo_mi_name_buf(char *buf, size_t buf_len, const uint8_t *mi, uint8_t mi_
*/
const char *osmo_mi_name(const uint8_t *mi, uint8_t mi_len)
{
- static char mi_name[10 + GSM48_MI_SIZE + 1];
+ static __thread char mi_name[10 + GSM48_MI_SIZE + 1];
return osmo_mi_name_buf(mi_name, sizeof(mi_name), mi, mi_len);
}
@@ -1150,7 +1150,7 @@ char *gsm48_pdisc_msgtype_name_buf(char *buf, size_t buf_len, uint8_t pdisc, uin
*/
const char *gsm48_pdisc_msgtype_name(uint8_t pdisc, uint8_t msg_type)
{
- static char namebuf[64];
+ static __thread char namebuf[64];
return gsm48_pdisc_msgtype_name_buf(namebuf, sizeof(namebuf), pdisc, msg_type);
}
@@ -1303,7 +1303,7 @@ char *osmo_gsm48_classmark_a5_name_buf(char *buf, size_t buf_len, const struct o
*/
const char *osmo_gsm48_classmark_a5_name(const struct osmo_gsm48_classmark *cm)
{
- static char buf[128];
+ static __thread char buf[128];
return osmo_gsm48_classmark_a5_name_buf(buf, sizeof(buf), cm);
}