Commit bdb62164 authored by Maria Matejka's avatar Maria Matejka
Browse files

Thread local storage is a must for parallel execution

parent 7c4b26c8
Loading
Loading
Loading
Loading
+10 −8
Original line number Diff line number Diff line
@@ -4,19 +4,21 @@ dnl ** (c) 1999 Martin Mares <mj@ucw.cz>
AC_DEFUN([BIRD_CHECK_THREAD_LOCAL],
[
  AC_CACHE_CHECK(
    [whether _Thread_local is known],
    [whether C11 thread local storage is available],
    [bird_cv_thread_local],
    AC_COMPILE_IFELSE([
      AC_LANG_PROGRAM(
        [
	  _Thread_local static int x = 42;
	],
	[]
      )
      AC_LANG_PROGRAM([ static _Thread_local int x = 42; ])
    ],
    [bird_cv_thread_local=yes],
      [
	AC_COMPILE_IFELSE([
	  AC_LANG_PROGRAM([ static __thread int x = 42; ])
	],
	[bird_cv_thread_local=old],
	[bird_cv_thread_local=no]
	)
      ]
    )
  )
])

+4 −5
Original line number Diff line number Diff line
@@ -121,13 +121,12 @@ fi

AC_PROG_CC
AC_PROG_CC_C99
if test -z "$GCC" ; then
  AC_MSG_ERROR([This program requires the GNU C Compiler.])
fi

BIRD_CHECK_THREAD_LOCAL
if test "$bird_cv_thread_local" = yes ; then
  AC_DEFINE([HAVE_THREAD_LOCAL], [1], [Define to 1 if _Thread_local is available])
if test "$bird_cv_thread_local" = no ; then
  AC_MSG_ERROR([Thread local storage not available])
elif test "$bird_cv_thread_local" = old ; then
  AC_DEFINE([HAVE_OLD_THREAD_LOCAL], [1], [Define to 1 if _Thread_local has to be defined as __thread])
fi

AC_CHECK_HEADER([stdatomic.h],
+2 −2
Original line number Diff line number Diff line
@@ -93,8 +93,8 @@ struct filter_state {
  int flags;
};

_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);

+2 −2
Original line number Diff line number Diff line
@@ -75,8 +75,8 @@ static inline int u64_cmp(u64 i1, u64 i2)
#define UNUSED __attribute__((unused))
#define PACKED __attribute__((packed))

#ifndef HAVE_THREAD_LOCAL
#define _Thread_local
#ifdef HAVE_OLD_THREAD_LOCAL
#define _Thread_local __thread
#endif

/* Microsecond time */