diff options
author | Harald Welte <laforge@gnumonks.org> | 2019-03-28 10:49:05 +0100 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2019-06-04 10:47:30 +0200 |
commit | 171ef826e1489031bc48745f29fa2d4657bf165f (patch) | |
tree | 08c8c32fae7f33f59df7621d6e3e8b8e127d856b /src/gsm/gsm23003.c | |
parent | 9b207419105c5e07504b1b7bf380eda07c127bb2 (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/gsm23003.c')
-rw-r--r-- | src/gsm/gsm23003.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/gsm/gsm23003.c b/src/gsm/gsm23003.c index a97ed079..4cc2671f 100644 --- a/src/gsm/gsm23003.c +++ b/src/gsm/gsm23003.c @@ -107,7 +107,7 @@ char *osmo_mcc_name_buf(char *buf, size_t buf_len, uint16_t mcc) */ const char *osmo_mcc_name(uint16_t mcc) { - static char buf[8]; + static __thread char buf[8]; return osmo_mcc_name_buf(buf, sizeof(buf), mcc); } @@ -158,7 +158,7 @@ char *osmo_mnc_name_c(const void *ctx, uint16_t mnc, bool mnc_3_digits) */ const char *osmo_mnc_name(uint16_t mnc, bool mnc_3_digits) { - static char buf[8]; + static __thread char buf[8]; return osmo_mnc_name_buf(buf, sizeof(buf), mnc, mnc_3_digits); } @@ -182,7 +182,7 @@ char *osmo_plmn_name_buf(char *buf, size_t buf_len, const struct osmo_plmn_id *p */ const char *osmo_plmn_name(const struct osmo_plmn_id *plmn) { - static char buf[16]; + static __thread char buf[16]; return osmo_plmn_name_buf(buf, sizeof(buf), plmn); } @@ -193,7 +193,7 @@ const char *osmo_plmn_name(const struct osmo_plmn_id *plmn) */ const char *osmo_plmn_name2(const struct osmo_plmn_id *plmn) { - static char buf[16]; + static __thread char buf[16]; return osmo_plmn_name_buf(buf, sizeof(buf), plmn); } @@ -230,7 +230,7 @@ char *osmo_lai_name_buf(char *buf, size_t buf_len, const struct osmo_location_ar */ const char *osmo_lai_name(const struct osmo_location_area_id *lai) { - static char buf[32]; + static __thread char buf[32]; return osmo_lai_name_buf(buf, sizeof(buf), lai); } @@ -265,7 +265,7 @@ char *osmo_cgi_name_buf(char *buf, size_t buf_len, const struct osmo_cell_global */ const char *osmo_cgi_name(const struct osmo_cell_global_id *cgi) { - static char buf[32]; + static __thread char buf[32]; return osmo_cgi_name_buf(buf, sizeof(buf), cgi); } @@ -276,7 +276,7 @@ const char *osmo_cgi_name(const struct osmo_cell_global_id *cgi) */ const char *osmo_cgi_name2(const struct osmo_cell_global_id *cgi) { - static char buf[32]; + static __thread char buf[32]; return osmo_cgi_name_buf(buf, sizeof(buf), cgi); } @@ -320,7 +320,7 @@ char *osmo_gummei_name_buf(char *buf, size_t buf_len, const struct osmo_gummei * */ const char *osmo_gummei_name(const struct osmo_gummei *gummei) { - static char buf[32]; + static __thread char buf[32]; return osmo_gummei_name_buf(buf, sizeof(buf), gummei); } |