summaryrefslogtreecommitdiffstats
path: root/src/gsm/gsm0808_utils.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/gsm0808_utils.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/gsm0808_utils.c')
-rw-r--r--src/gsm/gsm0808_utils.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/gsm/gsm0808_utils.c b/src/gsm/gsm0808_utils.c
index 26f7944d..70eed15e 100644
--- a/src/gsm/gsm0808_utils.c
+++ b/src/gsm/gsm0808_utils.c
@@ -611,7 +611,7 @@ int gsm0808_dec_lcls(struct osmo_lcls *lcls, const struct tlv_parsed *tp)
return ret;
}
-static char dbuf[256];
+static __thread char dbuf[256];
/*! Dump LCLS parameters (GCR excluded) into string for printing.
* \param[out] buf caller-allocated output string buffer
@@ -1819,7 +1819,7 @@ char *gsm0808_cell_id_name_buf(char *buf, size_t buflen, const struct gsm0808_ce
*/
const char *gsm0808_cell_id_name(const struct gsm0808_cell_id *cid)
{
- static char buf[64];
+ static __thread char buf[64];
return gsm0808_cell_id_name_buf(buf, sizeof(buf), cid);
}
@@ -1829,7 +1829,7 @@ const char *gsm0808_cell_id_name(const struct gsm0808_cell_id *cid)
*/
const char *gsm0808_cell_id_name2(const struct gsm0808_cell_id *cid)
{
- static char buf[64];
+ static __thread char buf[64];
return gsm0808_cell_id_name_buf(buf, sizeof(buf), cid);
}
@@ -1886,7 +1886,7 @@ int gsm0808_cell_id_list_name_buf(char *buf, size_t buflen, const struct gsm0808
* See also gsm0808_cell_id_list_name_buf(). */
const char *gsm0808_cell_id_list_name(const struct gsm0808_cell_id_list2 *cil)
{
- static char buf[1024];
+ static __thread char buf[1024];
gsm0808_cell_id_list_name_buf(buf, sizeof(buf), cil);
return buf;
}
@@ -1913,7 +1913,7 @@ char *gsm0808_channel_type_name_buf(char *buf, size_t buf_len, const struct gsm0
const char *gsm0808_channel_type_name(const struct gsm0808_channel_type *ct)
{
- static char buf[128];
+ static __thread char buf[128];
return gsm0808_channel_type_name_buf(buf, sizeof(buf), ct);
}