From: alegrand Date: Fri, 17 Dec 2004 05:43:49 +0000 (+0000) Subject: A few more functions usefull in MSG. They should not be written like functions though... X-Git-Tag: v3.3~4675 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/d5d8d2198da7c9d43ede3a7186cf0256bf1c59d7 A few more functions usefull in MSG. They should not be written like functions though as they are used in loop. Nevermind. git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@675 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- diff --git a/include/xbt/fifo.h b/include/xbt/fifo.h index 0993cacbfc..381c292df6 100644 --- a/include/xbt/fifo.h +++ b/include/xbt/fifo.h @@ -43,10 +43,15 @@ void xbt_fifo_freeitem(xbt_fifo_item_t); int xbt_fifo_size(xbt_fifo_t); -/* #define xbt_fifo_foreach(f,i,n,type) \ */ -/* for(i=xbt_fifo_getFirstitem(f); \ */ -/* ((i)?(n=(type)(i->content)):(NULL)); \ */ -/* i=xbt_fifo_getNextitem(i)) */ +xbt_fifo_item_t xbt_fifo_getFirstItem(xbt_fifo_t l); +xbt_fifo_item_t xbt_fifo_getNextItem(xbt_fifo_item_t i); +xbt_fifo_item_t xbt_fifo_getPrevItem(xbt_fifo_item_t i); + + +#define xbt_fifo_foreach(f,i,n,type) \ + for(i=xbt_fifo_getFirstItem(f); \ + ((i)?(n=(type)(xbt_fifo_get_item_content(i))):(NULL)); \ + i=xbt_fifo_getNextItem(i)) #endif /* _XBT_FIFO_H */ diff --git a/src/xbt/fifo.c b/src/xbt/fifo.c index b71e2132c6..3084fa7e03 100644 --- a/src/xbt/fifo.c +++ b/src/xbt/fifo.c @@ -308,4 +308,21 @@ int xbt_fifo_size(xbt_fifo_t f) return f->count; } +xbt_fifo_item_t xbt_fifo_getFirstItem(xbt_fifo_t l) +{ + return l->head; +} + +xbt_fifo_item_t xbt_fifo_getNextItem(xbt_fifo_item_t i) +{ + if(i) return i->next; + return NULL; +} + +xbt_fifo_item_t xbt_fifo_getPrevItem(xbt_fifo_item_t i) +{ + if(i) return i->prev; + return NULL; +} +