From f9db33d15dac13e98db4d98b07ed0e404897a55b Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Fri, 9 Apr 2010 19:43:54 -0400 Subject: [PATCH] Add LIST_ delaration to event_struct.h to supplment TAILQ_ Generally, LIST_ can be a little faster than TAILQ_ for most operations. We only need to use TAILQ_ when we care about traversing lists from tail-to-head, or we need to be able to add items to the end of the list. --- include/event2/event_struct.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/event2/event_struct.h b/include/event2/event_struct.h index 83ac2232..9d7111b4 100644 --- a/include/event2/event_struct.h +++ b/include/event2/event_struct.h @@ -69,6 +69,16 @@ struct { \ } #endif /* !TAILQ_ENTRY */ +/* Fix so that people don't have to run with */ +#ifndef LIST_ENTRY +#define _EVENT_DEFINED_LISTENTRY +#define LIST_ENTRY(type) \ +struct { \ + struct type *le_next; /* next element */ \ + struct type **le_prev; /* address of previous next element */ \ +} +#endif /* !TAILQ_ENTRY */ + struct event_base; struct event { TAILQ_ENTRY (event) (ev_active_next); @@ -131,6 +141,14 @@ TAILQ_HEAD (event_list, event); TAILQ_HEAD (evkeyvalq, evkeyval); #endif /* _EVENT_DEFINED_TQENTRY */ +#ifdef _EVENT_DEFINED_LISTENTRY +#undef LIST_ENTRY +struct event_dlist; +#undef _EVENT_DEFINED_LISTENTRY +#else +LIST_HEAD (event_dlist, event); +#endif /* _EVENT_DEFINED_LISTENTRY */ + #ifdef __cplusplus } #endif