From 2a0d6c32ac5ea8ca2fcfa25816024c59de5fbb19 Mon Sep 17 00:00:00 2001 From: Maria Matejka Date: Wed, 22 Apr 2020 17:14:26 +0200 Subject: [PATCH] Fix thread local storage support in GCC older than 4.9. Let's hope this will be history soon. --- aclocal.m4 | 11 ++++++++++- configure.ac | 4 +++- filter/filter.c | 4 ++-- proto/bgp/attrs.c | 2 +- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/aclocal.m4 b/aclocal.m4 index 1613d680..00453e5f 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -15,8 +15,17 @@ AC_DEFUN([BIRD_CHECK_THREAD_LOCAL], ) ], [bird_cv_thread_local=yes], + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM( + [ + static __thread int x = 42; + ], + [] + ) + ], + [bird_cv_thread_local=__thread], [bird_cv_thread_local=no] - ) + )) ) ]) diff --git a/configure.ac b/configure.ac index 7ef31fb4..31db7bd1 100644 --- a/configure.ac +++ b/configure.ac @@ -120,7 +120,9 @@ fi BIRD_CHECK_THREAD_LOCAL if test "$bird_cv_thread_local" = no ; then - AC_MSG_ERROR([Thread-local storage not available]) + AC_MSG_ERROR([Thread-local storage not available]) +elif test "$bird_cv_thread_local" != yes ; then + CFLAGS="$CFLAGS -D_Thread_local=$bird_cv_thread_local" fi BIRD_CHECK_PTHREADS diff --git a/filter/filter.c b/filter/filter.c index ca2bfc14..ec727740 100644 --- a/filter/filter.c +++ b/filter/filter.c @@ -91,8 +91,8 @@ struct filter_state { struct buffer buf; }; -_Thread_local static struct filter_state filter_state; -_Thread_local static struct filter_stack filter_stack; +static _Thread_local struct filter_state filter_state; +static _Thread_local struct filter_stack filter_stack; void (*bt_assert_hook)(int result, const struct f_line_item *assert); diff --git a/proto/bgp/attrs.c b/proto/bgp/attrs.c index 439de507..a7aa2805 100644 --- a/proto/bgp/attrs.c +++ b/proto/bgp/attrs.c @@ -2248,7 +2248,7 @@ bgp_rte_modify_stale(struct rte_storage *r, struct linpool *pool) if (ad && int_set_contains(ad, BGP_COMM_LLGR_STALE)) return r->attrs; - _Thread_local static struct { + static _Thread_local struct { rta a; u32 labels[MPLS_MAX_LABEL_STACK]; } aloc;