Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id ; Sun, 18 Aug 2002 15:15:29 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id ; Sun, 18 Aug 2002 15:15:29 -0400 Received: from dsl-213-023-039-196.arcor-ip.net ([213.23.39.196]:6618 "EHLO starship") by vger.kernel.org with ESMTP id ; Sun, 18 Aug 2002 15:15:28 -0400 Content-Type: text/plain; charset=US-ASCII From: Daniel Phillips To: linux-kernel@vger.kernel.org Subject: Generic list push/pop Date: Sun, 18 Aug 2002 21:21:41 +0200 X-Mailer: KMail [version 1.3.2] MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Message-Id: Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 889 Lines: 31 I took a run at writing generic single-linked list push and pop macros, to be used in the form: push_list(foo_list, foo_node); and foo_node = pop_list(foo_list); They came out predictably ugly: #define push_list(_LIST_, _NODE_) \ _NODE_->next = _LIST_; \ _LIST_ =_NODE_; #define pop_list(_LIST_) ({ \ typeof(_LIST_) _NODE_ = _LIST_; \ _LIST_ = _LIST_->next; \ _NODE_; }) These work but imho, they are too ugly to live. For one thing, they assume the link field is named 'next' and I don't see a nice way around that. Before moving them to my scraps.c file I thought I'd let other people throw some tomatoes at them. -- Daniel - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/