mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-12-22 09:41:54 +00:00
POSIX threads and thread-local storage is needed for concurrent execution
This commit is contained in:
parent
a845651bc5
commit
b5061659d3
14
aclocal.m4
vendored
14
aclocal.m4
vendored
@ -1,5 +1,6 @@
|
|||||||
dnl ** Additional Autoconf tests for BIRD configure script
|
dnl ** Additional Autoconf tests for BIRD configure script
|
||||||
dnl ** (c) 1999 Martin Mares <mj@ucw.cz>
|
dnl ** (c) 1999 Martin Mares <mj@ucw.cz>
|
||||||
|
dnl ** (c) 2021 Maria Matejka <mq@jmq.cz>
|
||||||
|
|
||||||
AC_DEFUN([BIRD_CHECK_THREAD_LOCAL],
|
AC_DEFUN([BIRD_CHECK_THREAD_LOCAL],
|
||||||
[
|
[
|
||||||
@ -9,14 +10,23 @@ AC_DEFUN([BIRD_CHECK_THREAD_LOCAL],
|
|||||||
AC_COMPILE_IFELSE([
|
AC_COMPILE_IFELSE([
|
||||||
AC_LANG_PROGRAM(
|
AC_LANG_PROGRAM(
|
||||||
[
|
[
|
||||||
_Thread_local static int x = 42;
|
static _Thread_local int x = 42;
|
||||||
],
|
],
|
||||||
[]
|
[]
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
[bird_cv_thread_local=yes],
|
[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]
|
[bird_cv_thread_local=no]
|
||||||
)
|
)])
|
||||||
)
|
)
|
||||||
])
|
])
|
||||||
|
|
||||||
|
46
configure.ac
46
configure.ac
@ -36,12 +36,6 @@ AC_ARG_ENABLE([memcheck],
|
|||||||
[enable_memcheck=yes]
|
[enable_memcheck=yes]
|
||||||
)
|
)
|
||||||
|
|
||||||
AC_ARG_ENABLE([pthreads],
|
|
||||||
[AS_HELP_STRING([--enable-pthreads], [enable POSIX threads support @<:@try@:>@])],
|
|
||||||
[],
|
|
||||||
[enable_pthreads=try]
|
|
||||||
)
|
|
||||||
|
|
||||||
AC_ARG_ENABLE([libssh],
|
AC_ARG_ENABLE([libssh],
|
||||||
[AS_HELP_STRING([--enable-libssh], [enable LibSSH support in RPKI @<:@try@:>@])],
|
[AS_HELP_STRING([--enable-libssh], [enable LibSSH support in RPKI @<:@try@:>@])],
|
||||||
[],
|
[],
|
||||||
@ -125,25 +119,19 @@ if test -z "$GCC" ; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
BIRD_CHECK_THREAD_LOCAL
|
BIRD_CHECK_THREAD_LOCAL
|
||||||
if test "$bird_cv_thread_local" = yes ; then
|
if test "$bird_cv_thread_local" = no ; then
|
||||||
AC_DEFINE([HAVE_THREAD_LOCAL], [1], [Define to 1 if _Thread_local is available])
|
AC_MSG_ERROR([This program requires thread local storage.])
|
||||||
|
elif test "$bird_cv_thread_local" != yes ; then
|
||||||
|
AC_DEFINE_UNQUOTED([_Thread_local], [$bird_cv_thread_local], [Legacy _Thread_local])
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test "$enable_pthreads" != no ; then
|
BIRD_CHECK_PTHREADS
|
||||||
BIRD_CHECK_PTHREADS
|
|
||||||
|
|
||||||
if test "$bird_cv_lib_pthreads" = yes ; then
|
if test "$bird_cv_lib_pthreads" = yes ; then
|
||||||
AC_DEFINE([USE_PTHREADS], [1], [Define to 1 if pthreads are enabled])
|
CFLAGS="$CFLAGS -pthread"
|
||||||
CFLAGS="$CFLAGS -pthread"
|
LDFLAGS="$LDFLAGS -pthread"
|
||||||
LDFLAGS="$LDFLAGS -pthread"
|
else
|
||||||
proto_bfd=bfd
|
AC_MSG_ERROR([POSIX threads not available.])
|
||||||
elif test "$enable_pthreads" = yes ; then
|
|
||||||
AC_MSG_ERROR([POSIX threads not available.])
|
|
||||||
fi
|
|
||||||
|
|
||||||
if test "$enable_pthreads" = try ; then
|
|
||||||
enable_pthreads="$bird_cv_lib_pthreads"
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# This is assumed to be necessary for proper BIRD build
|
# This is assumed to be necessary for proper BIRD build
|
||||||
@ -304,8 +292,7 @@ if test "$enable_mpls_kernel" != no ; then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
all_protocols="$proto_bfd babel bgp mrt ospf perf pipe radv rip rpki static"
|
all_protocols="bfd babel bgp mrt ospf perf pipe radv rip rpki static"
|
||||||
|
|
||||||
all_protocols=`echo $all_protocols | sed 's/ /,/g'`
|
all_protocols=`echo $all_protocols | sed 's/ /,/g'`
|
||||||
|
|
||||||
if test "$with_protocols" = all ; then
|
if test "$with_protocols" = all ; then
|
||||||
@ -351,9 +338,15 @@ case $sysdesc in
|
|||||||
esac
|
esac
|
||||||
|
|
||||||
AC_CHECK_HEADERS_ONCE([alloca.h syslog.h])
|
AC_CHECK_HEADERS_ONCE([alloca.h syslog.h])
|
||||||
AC_CHECK_HEADER([sys/mman.h], [AC_DEFINE([HAVE_MMAP], [1], [Define to 1 if mmap() is available.])])
|
AC_CHECK_HEADER([sys/mman.h], [AC_DEFINE([HAVE_MMAP], [1], [Define to 1 if mmap() is available.])], have_mman=no)
|
||||||
|
AC_CHECK_FUNC([aligned_alloc], [AC_DEFINE([HAVE_ALIGNED_ALLOC], [1], [Define to 1 if aligned_alloc() is available.])], have_aligned_alloc=no)
|
||||||
AC_CHECK_MEMBERS([struct sockaddr.sa_len], [], [], [#include <sys/socket.h>])
|
AC_CHECK_MEMBERS([struct sockaddr.sa_len], [], [], [#include <sys/socket.h>])
|
||||||
|
|
||||||
|
if test "$have_aligned_alloc" = "no" && test "$have_mman" = "no" ; then
|
||||||
|
AC_MSG_ERROR([No means of aligned alloc found. Need mmap() or aligned_alloc().])
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
AC_C_BIGENDIAN(
|
AC_C_BIGENDIAN(
|
||||||
[AC_DEFINE([CPU_BIG_ENDIAN], [1], [Define to 1 if cpu is big endian])],
|
[AC_DEFINE([CPU_BIG_ENDIAN], [1], [Define to 1 if cpu is big endian])],
|
||||||
[AC_DEFINE([CPU_LITTLE_ENDIAN], [1], [Define to 1 if cpu is little endian])],
|
[AC_DEFINE([CPU_LITTLE_ENDIAN], [1], [Define to 1 if cpu is little endian])],
|
||||||
@ -402,7 +395,7 @@ if test "$enable_debug" = yes ; then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test "enable_debug_expensive" = yes ; then
|
if test "$enable_debug_expensive" = yes ; then
|
||||||
AC_DEFINE([ENABLE_EXPENSIVE_CHECKS], [1], [Define to 1 if you want to run expensive consistency checks.])
|
AC_DEFINE([ENABLE_EXPENSIVE_CHECKS], [1], [Define to 1 if you want to run expensive consistency checks.])
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@ -467,7 +460,6 @@ AC_MSG_RESULT([ Object directory: $objdir])
|
|||||||
AC_MSG_RESULT([ Iproute2 directory: $iproutedir])
|
AC_MSG_RESULT([ Iproute2 directory: $iproutedir])
|
||||||
AC_MSG_RESULT([ System configuration: $sysdesc])
|
AC_MSG_RESULT([ System configuration: $sysdesc])
|
||||||
AC_MSG_RESULT([ Debugging: $enable_debug])
|
AC_MSG_RESULT([ Debugging: $enable_debug])
|
||||||
AC_MSG_RESULT([ POSIX threads: $enable_pthreads])
|
|
||||||
AC_MSG_RESULT([ Routing protocols: $protocols])
|
AC_MSG_RESULT([ Routing protocols: $protocols])
|
||||||
AC_MSG_RESULT([ LibSSH support in RPKI: $enable_libssh])
|
AC_MSG_RESULT([ LibSSH support in RPKI: $enable_libssh])
|
||||||
AC_MSG_RESULT([ Kernel MPLS support: $enable_mpls_kernel])
|
AC_MSG_RESULT([ Kernel MPLS support: $enable_mpls_kernel])
|
||||||
|
@ -77,10 +77,6 @@ static inline int u64_cmp(u64 i1, u64 i2)
|
|||||||
#define STATIC_ASSERT(EXP) _Static_assert(EXP, #EXP)
|
#define STATIC_ASSERT(EXP) _Static_assert(EXP, #EXP)
|
||||||
#define STATIC_ASSERT_MSG(EXP,MSG) _Static_assert(EXP, MSG)
|
#define STATIC_ASSERT_MSG(EXP,MSG) _Static_assert(EXP, MSG)
|
||||||
|
|
||||||
#ifndef HAVE_THREAD_LOCAL
|
|
||||||
#define _Thread_local
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Microsecond time */
|
/* Microsecond time */
|
||||||
|
|
||||||
typedef s64 btime;
|
typedef s64 btime;
|
||||||
|
10
lib/timer.c
10
lib/timer.c
@ -40,8 +40,6 @@
|
|||||||
struct timeloop main_timeloop;
|
struct timeloop main_timeloop;
|
||||||
|
|
||||||
|
|
||||||
#ifdef USE_PTHREADS
|
|
||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
/* Data accessed and modified from proto/bfd/io.c */
|
/* Data accessed and modified from proto/bfd/io.c */
|
||||||
@ -62,14 +60,6 @@ timeloop_init_current(void)
|
|||||||
|
|
||||||
void wakeup_kick_current(void);
|
void wakeup_kick_current(void);
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
/* Just use main timelooop */
|
|
||||||
static inline struct timeloop * timeloop_current(void) { return &main_timeloop; }
|
|
||||||
static inline void timeloop_init_current(void) { }
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
btime
|
btime
|
||||||
current_time(void)
|
current_time(void)
|
||||||
{
|
{
|
||||||
|
@ -36,8 +36,6 @@ static list *current_log_list;
|
|||||||
static char *current_syslog_name; /* NULL -> syslog closed */
|
static char *current_syslog_name; /* NULL -> syslog closed */
|
||||||
|
|
||||||
|
|
||||||
#ifdef USE_PTHREADS
|
|
||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
static pthread_mutex_t log_mutex;
|
static pthread_mutex_t log_mutex;
|
||||||
@ -48,15 +46,6 @@ static pthread_t main_thread;
|
|||||||
void main_thread_init(void) { main_thread = pthread_self(); }
|
void main_thread_init(void) { main_thread = pthread_self(); }
|
||||||
static int main_thread_self(void) { return pthread_equal(pthread_self(), main_thread); }
|
static int main_thread_self(void) { return pthread_equal(pthread_self(), main_thread); }
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
static inline void log_lock(void) { }
|
|
||||||
static inline void log_unlock(void) { }
|
|
||||||
void main_thread_init(void) { }
|
|
||||||
static int main_thread_self(void) { return 1; }
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef HAVE_SYSLOG_H
|
#ifdef HAVE_SYSLOG_H
|
||||||
#include <sys/syslog.h>
|
#include <sys/syslog.h>
|
||||||
|
Loading…
Reference in New Issue
Block a user