Date: Wed, 9 May 2007 00:17:14 +0300 From: Kostik Belousov <kostikbel@gmail.com> To: John Baldwin <jhb@freebsd.org> Cc: Hans Petter Selasky <hselasky@c2i.net>, Giorgos Keramidas <keramida@freebsd.org>, freebsd-arch@freebsd.org Subject: Re: Missing LIST_PREV() ? Message-ID: <20070508211714.GQ83173@deviant.kiev.zoral.com.ua> In-Reply-To: <200705081128.25708.jhb@freebsd.org> References: <200705051617.34162.hselasky@c2i.net> <20070507202034.GA80846@kobe.laptop> <20070507202517.GA88340@kobe.laptop> <200705081128.25708.jhb@freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
--SlnaBQtdWG0gYnqZ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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 <keramida@freebsd.org> wrote: > > >On 2007-05-05 16:17, Hans Petter Selasky <hselasky@c2i.net> 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) =3D=3D 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. >=20 > Looks like an ugly version of offsetof() >=20 =2E.. > I'm not sure how portable offsetof() would be though. In general if you = want=20 offsetof() itself is defined by C standard to be present both in freestanding and hosted environment (and be available by stddef.h). --SlnaBQtdWG0gYnqZ Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (FreeBSD) iD8DBQFGQOjZC3+MBN1Mb4gRAvY/AJ9BnvqZFfK0UeYzO5dbnOasyent3wCeMLfE wodA2mOekcCVFOA5BnW/FB0= =8kZi -----END PGP SIGNATURE----- --SlnaBQtdWG0gYnqZ--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20070508211714.GQ83173>