From owner-svn-src-head@FreeBSD.ORG Thu May 28 01:14:55 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 23624106567B; Thu, 28 May 2009 01:14:55 +0000 (UTC) (envelope-from zml@FreeBSD.org) Received: from seaxch10.isilon.com (seaxch10.isilon.com [74.85.160.26]) by mx1.freebsd.org (Postfix) with ESMTP id F40118FC23; Thu, 28 May 2009 01:14:54 +0000 (UTC) (envelope-from zml@FreeBSD.org) Received: from famine.isilon.com ([10.54.190.95]) by seaxch10.isilon.com with Microsoft SMTPSVC(6.0.3790.1830); Wed, 27 May 2009 18:02:21 -0700 Received: from zloafman by famine.isilon.com with local (Exim 4.69) (envelope-from ) id 1M9U0j-00025D-6D; Wed, 27 May 2009 18:02:21 -0700 Date: Wed, 27 May 2009 18:02:21 -0700 From: Zachary Loafman To: Ed Schouten Message-ID: <20090528010220.GF3704@isilon.com> References: <200905271636.n4RGasNe003922@svn.freebsd.org> <20090527182807.GG48776@hoeg.nl> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20090527182807.GG48776@hoeg.nl> User-Agent: Mutt/1.5.18 (2008-05-17) X-OriginalArrivalTime: 28 May 2009 01:02:21.0482 (UTC) FILETIME=[F47958A0:01C9DF2F] Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r192908 - in head: share/man/man9 sys/confsys/kern sys/sys X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 May 2009 01:14:55 -0000 On Wed, May 27, 2009 at 11:28:07AM -0700, Ed Schouten wrote: > Hi Zach, > > * Zachary Loafman wrote: > > head/sys/sys/queue.h > > This part of the patch is not in the email, so I'll just link it here: > > http://svn.freebsd.org/viewvc/base/head/sys/sys/queue.h?r1=191535&r2=192908 > > In other macros in this header file, we try to use as many _NEXT() and > _PREV() invocations as possible, to abstract the structure field names. > Maybe we could change _SWAP() macros to do the same? Ed - I started to do this, but let's run through it: > #define STAILQ_SWAP(head1, head2, type) do { \ > struct type *swap_first = STAILQ_FIRST(head1); \ > struct type **swap_last = (head1)->stqh_last; \ > STAILQ_FIRST(head1) = STAILQ_FIRST(head2); \ > (head1)->stqh_last = (head2)->stqh_last; \ > STAILQ_FIRST(head2) = swap_first; \ > (head2)->stqh_last = swap_last; \ > if (STAILQ_EMPTY(head1)) \ > (head1)->stqh_last = &STAILQ_FIRST(head1); \ > if (STAILQ_EMPTY(head2)) \ > (head2)->stqh_last = &STAILQ_FIRST(head2); \ > } while (0) There is no macro that references just ->stqh_last. As it's internal to the inner workings, I'm not sure there needs to be. The others are macro-ized already. > #define LIST_SWAP(head1, head2, type, field) do { \ > struct type *swap_tmp = LIST_FIRST((head1)); \ > LIST_FIRST((head1)) = LIST_FIRST((head2)); \ > LIST_FIRST((head2)) = swap_tmp; \ > if ((swap_tmp = LIST_FIRST((head1))) != NULL) \ > swap_tmp->field.le_prev = &LIST_FIRST((head1)); \ > if ((swap_tmp = LIST_FIRST((head2))) != NULL) \ > swap_tmp->field.le_prev = &LIST_FIRST((head2)); \ > } while (0) Again, there's no macro for .le_prev. Everything else is macro-ized. > #define TAILQ_SWAP(head1, head2, type, field) do { \ > struct type *swap_first = (head1)->tqh_first; \ > struct type **swap_last = (head1)->tqh_last; \ > (head1)->tqh_first = (head2)->tqh_first; \ > (head1)->tqh_last = (head2)->tqh_last; \ > (head2)->tqh_first = swap_first; \ > (head2)->tqh_last = swap_last; \ > if ((swap_first = (head1)->tqh_first) != NULL) \ > swap_first->field.tqe_prev = &(head1)->tqh_first; \ > else \ > (head1)->tqh_last = &(head1)->tqh_first; \ > if ((swap_first = (head2)->tqh_first) != NULL) \ > swap_first->field.tqe_prev = &(head2)->tqh_first; \ > else \ > (head2)->tqh_last = &(head2)->tqh_first; \ > } while (0) This is the only one where we could throw some macro replacements in. But consider this: > (head1)->tqh_first = (head2)->tqh_first; \ > (head1)->tqh_last = (head2)->tqh_last; \ versus > TAILQ_FIRST(head1) = TAILQ_FIRST(head2); \ > (head1)->tqh_last = (head2)->tqh_last; \ I personally find the first form clearer to skim through visually. The second form moves 'head1' and 'head2' around. It's not like it's hard to follow, but I think the first is clearer to read. I don't think the TAILQ_FIRST buys you much here. -- Zach Loafman | Staff Engineer | Isilon Systems