From owner-freebsd-arch@FreeBSD.ORG Tue May 8 21:51:44 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 7C71D16A402 for ; Tue, 8 May 2007 21:51:44 +0000 (UTC) (envelope-from julian@elischer.org) Received: from outL.internet-mail-service.net (outL.internet-mail-service.net [216.240.47.235]) by mx1.freebsd.org (Postfix) with ESMTP id 677FA13C45E for ; Tue, 8 May 2007 21:51:44 +0000 (UTC) (envelope-from julian@elischer.org) Received: from mx0.idiom.com (HELO idiom.com) (216.240.32.160) by out.internet-mail-service.net (qpsmtpd/0.32) with ESMTP; Tue, 08 May 2007 14:51:44 -0700 Received: from julian-mac.elischer.org (nat.ironport.com [63.251.108.100]) by idiom.com (Postfix) with ESMTP id AAD6F125A24; Tue, 8 May 2007 14:51:43 -0700 (PDT) Message-ID: <4640F0EE.2080206@elischer.org> Date: Tue, 08 May 2007 14:51:42 -0700 From: Julian Elischer User-Agent: Thunderbird 2.0.0.0 (Macintosh/20070326) MIME-Version: 1.0 To: Kostik Belousov References: <200705051617.34162.hselasky@c2i.net> <20070507202034.GA80846@kobe.laptop> <20070507202517.GA88340@kobe.laptop> <200705081128.25708.jhb@freebsd.org> <20070508211714.GQ83173@deviant.kiev.zoral.com.ua> In-Reply-To: <20070508211714.GQ83173@deviant.kiev.zoral.com.ua> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-arch@freebsd.org, Giorgos Keramidas , Hans Petter Selasky 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: Tue, 08 May 2007 21:51:44 -0000 Kostik Belousov wrote: > On Tue, May 08, 2007 at 11:28:25AM -0400, John Baldwin wrote: >> On Monday 07 May 2007 04:25:18 pm Giorgos Keramidas wrote: >>> 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. >> Looks like an ugly version of offsetof() >> > ... >> I'm not sure how portable offsetof() would be though. In general if you want > > offsetof() itself is defined by C standard to be present both in > freestanding and hosted environment (and be available by stddef.h). You learn something every day! interesting (but still scary)..