From: Vincent Bernat Date: Fri, 12 Dec 2008 09:55:42 +0000 (+0100) Subject: Add SLIST support for libc not shipping it (like Sarge) X-Git-Tag: 0.3~8 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9d09937f2fad244edb796e1cdefbfff380788806;p=thirdparty%2Flldpd.git Add SLIST support for libc not shipping it (like Sarge) --- diff --git a/configure.ac b/configure.ac index c723c10f..ad354037 100644 --- a/configure.ac +++ b/configure.ac @@ -40,6 +40,8 @@ AC_ARG_WITH(privsep-chroot, # Checks for header files. AC_CHECK_DECLS([TAILQ_FIRST, TAILQ_NEXT, TAILQ_FOREACH, TAILQ_EMPTY],[],[],[[#include ]]) +AC_CHECK_DECLS([SLIST_HEAD, SLIST_ENTRY, SLIST_INIT, SLIST_INSERT_HEAD],[],[],[[#include ]]) +AC_CHECK_DECLS([SLIST_FIRST, SLIST_NEXT, SLIST_REMOVE_HEAD, SLIST_EMPTY],[],[],[[#include ]]) AC_CHECK_DECLS([PACKET_ORIGDEV],[],[],[[#include ]]) AC_CHECK_DECLS([ADVERTISED_2500baseX_Full, ADVERTISED_Pause, ADVERTISED_Asym_Pause], [],[],[[#include ]]) diff --git a/src/compat.h b/src/compat.h index 21235637..ac649d30 100644 --- a/src/compat.h +++ b/src/compat.h @@ -48,6 +48,51 @@ #define TAILQ_EMPTY(head) ((head)->tqh_first == NULL) #endif +#if !HAVE_DECL_SLIST_HEAD +#define SLIST_HEAD(name, type) \ +struct name { \ + struct type *slh_first; /* first element */ \ +} +#endif + +#if !HAVE_DECL_SLIST_ENTRY +#define SLIST_ENTRY(type) \ +struct { \ + struct type *sle_next; /* next element */ \ +} +#endif + +#if !HAVE_DECL_SLIST_INIT +#define SLIST_INIT(head) do { \ + (head)->slh_first = NULL; \ +} while (/*CONSTCOND*/0) +#endif + +#if !HAVE_DECL_SLIST_INSERT_HEAD +#define SLIST_INSERT_HEAD(head, elm, field) do { \ + (elm)->field.sle_next = (head)->slh_first; \ + (head)->slh_first = (elm); \ +} while (/*CONSTCOND*/0) +#endif + +#if !HAVE_DECL_SLIST_REMOVE_HEAD +#define SLIST_REMOVE_HEAD(head, field) do { \ + (head)->slh_first = (head)->slh_first->field.sle_next; \ +} while (/*CONSTCOND*/0) +#endif + +#if !HAVE_DECL_SLIST_EMPTY +#define SLIST_EMPTY(head) ((head)->slh_first == NULL) +#endif + +#if !HAVE_DECL_SLIST_FIRST +#define SLIST_FIRST(head) ((head)->slh_first) +#endif + +#if !HAVE_DECL_SLIST_NEXT +#define SLIST_NEXT(elm, field) ((elm)->field.sle_next) +#endif + #if !HAVE_DECL_ADVERTISED_PAUSE #define ADVERTISED_Pause (1 << 13) #endif