From owner-freebsd-arch@FreeBSD.ORG Mon May 7 20:38:35 2007 Return-Path: X-Original-To: freebsd-arch@freebsd.org Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 2C83316A402 for ; Mon, 7 May 2007 20:38:35 +0000 (UTC) (envelope-from keramida@freebsd.org) Received: from igloo.linux.gr (igloo.linux.gr [62.1.205.36]) by mx1.freebsd.org (Postfix) with ESMTP id 9A69713C447 for ; Mon, 7 May 2007 20:38:34 +0000 (UTC) (envelope-from keramida@freebsd.org) Received: from kobe.laptop (host5.bedc.ondsl.gr [62.103.39.229]) (authenticated bits=128) by igloo.linux.gr (8.13.8/8.13.8/Debian-3) with ESMTP id l47KPcXP025429 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Mon, 7 May 2007 23:25:43 +0300 Received: from kobe.laptop (kobe.laptop [127.0.0.1]) by kobe.laptop (8.14.1/8.14.1) with ESMTP id l47KPJXN088693; Mon, 7 May 2007 23:25:31 +0300 (EEST) (envelope-from keramida@freebsd.org) Received: (from keramida@localhost) by kobe.laptop (8.14.1/8.14.1/Submit) id l47KPISm088692; Mon, 7 May 2007 23:25:18 +0300 (EEST) (envelope-from keramida@freebsd.org) Date: Mon, 7 May 2007 23:25:18 +0300 From: Giorgos Keramidas To: Hans Petter Selasky Message-ID: <20070507202517.GA88340@kobe.laptop> References: <200705051617.34162.hselasky@c2i.net> <20070507202034.GA80846@kobe.laptop> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20070507202034.GA80846@kobe.laptop> X-Hellug-MailScanner: Found to be clean X-Hellug-MailScanner-SpamCheck: not spam, SpamAssassin (not cached, score=-3.812, required 5, autolearn=not spam, ALL_TRUSTED -1.80, AWL 0.59, BAYES_00 -2.60) X-Hellug-MailScanner-From: keramida@freebsd.org X-Spam-Status: No Cc: freebsd-arch@freebsd.org Subject: Re: Missing LIST_PREV() ? X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 May 2007 20:38:35 -0000 On 2007-05-07 23:20, Giorgos Keramidas wrote: >On 2007-05-05 16:17, Hans Petter Selasky 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 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