Re: Missing LIST_PREV() ?

On 2007-05-07 23:20, Giorgos Keramidas <keramida@xxxxxxxxxxx> wrote:
On 2007-05-05 16:17, Hans Petter Selasky <hselasky@xxxxxxx> wrote:

Why should LISTs only be forward traversable? The following piece of
code make lists backward traversable:


+#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()

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
To unsubscribe, send any mail to "freebsd-arch-unsubscribe@xxxxxxxxxxx"

Relevant Pages

  • Solaris 10 and Brocade switch question?
    ... I have just built a solaris 10 06/06 sparc server with the latest Sun ... It lists some packages ... I looked for some of the packages that are required and I have about ...
  • Re: gfortran 4.7.2, OpenMP DEFAULT NONE, and parameter arrays.
    ... I could not help but notice that gfortran is NOT on the list of compilers ... trying out multiple compilers for large systems that others may wish to use. ... Note that NLCDTYPES is a PARAMETER, so should not be in the ... SHARED nor PRIVATE lists. ...
  • Re: C is too old? opinions?
    ... jacob navia wrote: ... If your C *must* be 100% standard compatible amongst ALL compilers ... Comeau C/C++ ... You can generate lists of this kind for pretty much any ...
  • Re: asm
    ... > commands for different compilers? ... > commands that are available for NASM, for HLA, MASM, ... I'll recompile the lists and set them up on a ... If you're mainly interested in the instruction set, ...
  • Re: Old GCC
    ... On Sat, 2005-01-22 at 18:27 -0500, Steven Pasternak wrote: ... I just want to produce rpms that will work on my fedora system and my ... you use to build the "ancient" compilers you mention. ... and subscribe to the following lists: ...