linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Zach Brown <zab@zabbo.net>
To: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH][2.5] Single linked lists for Linux, overly complicated v2
Date: Thu, 26 Sep 2002 20:57:27 -0400	[thread overview]
Message-ID: <20020926205727.T13817@bitchcake.off.net> (raw)
In-Reply-To: <Pine.LNX.4.44.0209261337290.7827-100000@hawkeye.luckynet.adm>; from thunder@lightweight.ods.org on Thu, Sep 26, 2002 at 01:43:41PM -0600

> My problem is just: where to put the old _entry? Anyway, since we're 
> talking about list entry deletion, we could copy it nowhere and just 
> overwrite it with _entry->next...

honestly, I think if you're contemplating this kind of thing, you've
gone too far with the design.  it should be dirt friggin simple', like
what wli posted a while ago with struct list.  if you need more, you
really should just use list_head and be done with it.  (restartable list
walking?  why did you stop walking in the first place?  oh, you didn't
mean restartable, you meant able to start walking at an arbitrary
position?  back to list_head.. )

Here's something I'd consider using if it were in the kernel.  if others
agree, I can finalize and submit it.

( yeah, a lot of it is stinky, like the requirement that users magically
have the right member in their structs.  I have no deep love for the
interface.  at least this passes basic usage tests..)

#define TSLIST_DECLARE(type, name) 		\
	type *name = NULL

#define TSLIST_MEMBER_INIT(member) 		\
	NULL

#define INIT_TSLIST_MEMBER(member) 		\
	do {					\
		(member)->_slist_next = NULL;	\
	} while (0)

#define tslist_on_list(_head,_elem) 		\
	( (_elem)->_slist_next != NULL || _head == _elem )

#define tslist_push tslist_add

#define tslist_add(_head, _elem) 			\
	do {  						\
		BUG_ON(tslist_on_list(_head, _elem));	\
		(_elem)->_slist_next = (_head);		\
		(_head) = (_elem);			\
	} while(0)

#define tslist_pop(_head)					\
	({							\
	 	typeof(_head) _ret = _head;			\
		if ( _head ) {					\
			_ret = _head;				\
			_head = _head->_slist_next;		\
			_ret->_slist_next = NULL;		\
		}						\
		_ret;						\
	})

#define __tslist_walk_del(_start, _elem)			\
	do {							\
		typeof(_start) _pos, _prev = _start;		\
		for (; _prev && (_pos = _prev->_slist_next) ;	\
			_prev = _pos ) {			\
			if ( _pos != _elem )			\
				continue;			\
			_prev->_slist_next = (_elem)->_slist_next;\
			(_elem)->_slist_next = NULL;		\
			break;					\
		}						\
	} while (0)
		

#define tslist_del(_head, _elem) 					\
	do {  								\
		if ( _head == _elem ) {					\
			_head = (_elem)->_slist_next;			\
			(_elem)->_slist_next = NULL;			\
		} else {						\
			__tslist_walk_del(_head, _elem);		\
		}							\
	} while (0)

#define tslist_for_each(_pos, _head)				\
	for ( _pos = _head ; _pos ; _pos = _pos->_slist_next )

  parent reply	other threads:[~2002-09-27  0:52 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20020926142547.N13817@bitchcake.off.net>
2002-09-26 18:45 ` [PATCH][2.5] Single linked lists for Linux, overly complicated v2 Thunder from the hill
2002-09-26 19:29   ` Rik van Riel
2002-09-26 19:43     ` Thunder from the hill
2002-09-26 20:00       ` Rik van Riel
2002-09-26 20:10         ` Thunder from the hill
2002-09-26 21:13         ` Thunder from the hill
2002-09-26 21:19           ` Thunder from the hill
2002-09-27  0:57       ` Zach Brown [this message]
2002-09-27 20:08         ` Thunder from the hill
2002-09-27 20:39           ` Zach Brown
2002-09-27 20:52             ` Thunder from the hill
2002-09-28  9:45         ` Thunder from the hill
2002-09-30 19:37         ` Daniel Phillips
2002-09-30 20:04           ` Zach Brown
     [not found]             ` <E17w7N8-0005px-00@starship>
2002-09-30 20:50               ` Zach Brown
2002-10-01 16:05             ` Daniel Phillips
2002-09-26 19:49     ` David B. Stevens
     [not found] <924963807@toto.iv>
2002-09-27  3:56 ` Peter Chubb
2002-09-27  7:27   ` Arnaldo Carvalho de Melo
2002-09-27 14:56   ` Thunder from the hill
2002-09-30 19:48   ` Daniel Phillips
2002-09-26 17:41 Lightweight Patch Manager
2002-09-26 17:53 ` Rik van Riel
2002-09-26 18:26   ` Thunder from the hill

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20020926205727.T13817@bitchcake.off.net \
    --to=zab@zabbo.net \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).