Commit a0bd04c0 authored by Jan Maria Matejka's avatar Jan Maria Matejka
Browse files

Merge branch 'mq-coro' into mq-config-new

parents 118c443a 1e52cd6a
Loading
Loading
Loading
Loading
+24 −2
Original line number Diff line number Diff line
@@ -17,8 +17,6 @@ AC_DEFUN([BIRD_CHECK_PTHREADS],
	    [
	      pthread_t pt;
	      pthread_create(&pt, NULL, NULL, NULL);
	      pthread_spinlock_t lock;
	      pthread_spin_lock(&lock);
	    ]
	  )
	],
@@ -31,6 +29,30 @@ AC_DEFUN([BIRD_CHECK_PTHREADS],
  CFLAGS="$bird_tmp_cflags"
])

dnl ** Android API before version 24 doesn't implement spinlocks.
AC_DEFUN([BIRD_CHECK_PTHREAD_SPINLOCK],
[
  AC_CACHE_CHECK(
    [whether POSIX threads provide spinlocks],
    [bird_cv_lib_pthread_spinlock],
    [
      AC_LINK_IFELSE(
	[
	  AC_LANG_PROGRAM(
	    [ #include <pthread.h> ],
	    [
	      pthread_spinlock_t lock;
	      pthread_spin_lock(&lock);
	    ]
	  )
	],
	[bird_cv_lib_pthread_spinlock=yes],
	[bird_cv_lib_pthread_spinlock=no]
      )
    ]
  )
])

AC_DEFUN([BIRD_CHECK_MPLS_KERNEL],
[
  AC_CACHE_CHECK(
+7 −1
Original line number Diff line number Diff line
@@ -120,7 +120,13 @@ if test "$enable_pthreads" != no ; then
    AC_DEFINE([USE_PTHREADS], [1], [Define to 1 if pthreads are enabled])
    CFLAGS="$CFLAGS -pthread"
    LDFLAGS="$LDFLAGS -pthread"

    BIRD_CHECK_PTHREAD_SPINLOCK
    if test "$bird_cv_lib_pthread_spinlock" = yes ; then
      AC_DEFINE([USE_PTHREAD_SPINLOCK], [1], [Define to 1 if pthreads provide spinlocks])
      proto_bfd=bfd
    fi

  elif test "$enable_pthreads" = yes ; then
    AC_MSG_ERROR([POSIX threads not available.])
  fi
+1 −1
Original line number Diff line number Diff line
@@ -653,7 +653,7 @@ agreement").

	<tag><label id="proto-description">description "<m/text/"</tag>
	This is an optional description of the protocol. It is displayed as a
	part of the output of 'show route all' command.
	part of the output of 'show protocols all' command.

	<tag><label id="proto-vrf">vrf "<m/text/"</tag>
	Associate the protocol with specific VRF. The protocol will be

lib/coroutine.h

0 → 100644
+26 −0
Original line number Diff line number Diff line
/*
 *	BIRD Coroutines
 *
 *	(c) 2017 Martin Mares <mj@ucw.cz>
 *
 *	Can be freely distributed and used under the terms of the GNU GPL.
 */

#ifndef _BIRD_COROUTINE_H_
#define _BIRD_COROUTINE_H_

#include "lib/event.h"

// The structure is completely opaque, implemented by sysdep
typedef struct coroutine coroutine;

coroutine *coro_new(struct pool *pool, void (*entry_point)(void *arg), void *arg);
void coro_suspend(void);
void coro_resume(coroutine *c);
void coro_done(event *e) NORET;

struct birdsock;
int coro_sk_read(struct birdsock *s);
void coro_sk_write(struct birdsock *s, unsigned len);

#endif
+5 −0
Original line number Diff line number Diff line
@@ -36,6 +36,8 @@ struct ssh_sock {
};
#endif

struct coroutine;

typedef struct birdsock {
  resource r;
  pool *pool;				/* Pool where incoming connections should be allocated (for SK_xxx_PASSIVE) */
@@ -79,6 +81,9 @@ typedef struct birdsock {
  char *password;			/* Password for MD5 authentication */
  const char *err;			/* Error message */
  struct ssh_sock *ssh;			/* Used in SK_SSH */

  struct coroutine *rx_coroutine;
  struct coroutine *tx_coroutine;
} sock;

sock *sock_new(pool *);			/* Allocate new socket */
Loading