Re: Missing LIST_PREV() ?
- From: Giorgos Keramidas <keramida@xxxxxxxxxxx>
- Date: Mon, 7 May 2007 23:25:18 +0300
On 2007-05-07 23:20, Giorgos Keramidas <keramida@xxxxxxxxxxx> wrote:
On 2007-05-05 16:17, Hans Petter Selasky <hselasky@xxxxxxx> wrote:
Hi,
Why should LISTs only be forward traversable? The following piece of
code make lists backward traversable:
/sys/sys/queue.h:
+#define LIST_PREV(head,elm,field) \
+ (((elm) == LIST_FIRST(head)) ? ((__typeof(elm))0) : \
+ ((__typeof(elm))(((uint8_t *)((elm)->field.le_prev)) - \
+ ((uint8_t *)&LIST_NEXT((__typeof(elm))0,field)))))
Any comments?
1. The use of (uint8_t *) casts is relatively ugly.
2. What does LIST_PREV give us that cannot be done with TAILQ_PREV()
already?
Even more importantly, which I missed in my original look
(3) The use of the gcc-specific __typeof() extension makes this unusable
with other compilers.
The entire <sys/queue.h> header is otherwise very portable and I already
use it successfully on other systems too (i.e. Solaris with the Sun
Studio 11 compilers). Introducing unportable constructs like __typeof()
shouldn't be allowed, IMHO.
- Giorgos
_______________________________________________
freebsd-arch@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-arch
To unsubscribe, send any mail to "freebsd-arch-unsubscribe@xxxxxxxxxxx"
- Follow-Ups:
- Re: Missing LIST_PREV() ?
- From: John Baldwin
- Re: Missing LIST_PREV() ?
- References:
- Missing LIST_PREV() ?
- From: Hans Petter Selasky
- Re: Missing LIST_PREV() ?
- From: Giorgos Keramidas
- Missing LIST_PREV() ?
- Prev by Date: Re: Missing LIST_PREV() ?
- Next by Date: Re: Missing LIST_PREV() ?
- Previous by thread: Re: Missing LIST_PREV() ?
- Next by thread: Re: Missing LIST_PREV() ?
- Index(es):
Relevant Pages
|