X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=mware%2Flist.h;h=8f57f448bced6c4952401ec058d54cae4082e23c;hb=8eb928a7c1e446a2a0606a48a93ab732e5e14229;hp=2d8e737aecf4e3fe078c897742bfc5f48a296de9;hpb=96f0ef786b54356c56cc3d4e4f0838df2505cfcc;p=bertos.git diff --git a/mware/list.h b/mware/list.h index 2d8e737a..8f57f448 100755 --- a/mware/list.h +++ b/mware/list.h @@ -13,6 +13,12 @@ /* * $Log$ + * Revision 1.4 2004/07/18 22:12:53 bernie + * Fix warnings with GCC 3.3.2. + * + * Revision 1.3 2004/07/18 22:01:43 bernie + * REMHEAD(), REMTAIL(): Move to list.h as inline functions. + * * Revision 1.2 2004/06/03 11:27:09 bernie * Add dual-license information. * @@ -111,15 +117,40 @@ typedef struct _List /*! Tell whether a list is empty */ #define ISLISTEMPTY(l) ( (l)->head == (Node *)(&(l)->null) ) -/*! \name Extract an element from the head/tail of the list. If the list empty, return NULL. */ -/*\{*/ -#define REMHEAD(l) _list_rem_head(l) -#define REMTAIL(l) _list_rem_tail(l) -/*\}*/ +/*! + * \name Unlink a node from the head of the list \a l. + * \return Pointer to node, or NULL if the list was empty. + */ +INLINE Node *REMHEAD(List *l); +INLINE Node *REMHEAD(List *l) +{ + Node *n; + + if (ISLISTEMPTY(l)) + return (Node *)0; + + n = l->head; + l->head = n->succ; + n->succ->pred = (Node *)l; + return n; +} + +/*! + * \name Unlink a node from the tail of the list \a l. + * \return Pointer to node, or NULL if the list was empty. + */ +INLINE Node *REMTAIL(List *l); +INLINE Node *REMTAIL(List *l) +{ + Node *n; -/* Prototypes for out-of-line functions */ -Node *_list_rem_head(List *l); -Node *_list_rem_tail(List *l); + if (ISLISTEMPTY(l)) + return (Node *)0; + n = l->tail; + l->tail = n->pred; + n->pred->succ = (Node *)&l->null; + return n; +} #endif /* MWARE_LIST_H */