From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161152AbXCGBl5 (ORCPT ); Tue, 6 Mar 2007 20:41:57 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1161149AbXCGBl4 (ORCPT ); Tue, 6 Mar 2007 20:41:56 -0500 Received: from mail32.syd.optusnet.com.au ([211.29.132.63]:59903 "EHLO mail32.syd.optusnet.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161155AbXCGBlz (ORCPT ); Tue, 6 Mar 2007 20:41:55 -0500 From: Con Kolivas To: linux-kernel@vger.kernel.org, ck@vds.kolivas.org, Peter Zijlstra Subject: [PATCH] [RSDL-mm 1/6] lists: add list splice tail Date: Wed, 7 Mar 2007 12:27:00 +1100 User-Agent: KMail/1.9.5 MIME-Version: 1.0 Content-Disposition: inline X-Length: 2779 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Message-Id: <200703071227.00630.kernel@kolivas.org> Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Add a list_splice_tail variant of list_splice. Patch-by: Peter Zijlstra Signed-off-by: Con Kolivas --- include/linux/list.h | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) Index: linux-2.6.21-rc2-mm2/include/linux/list.h =================================================================== --- linux-2.6.21-rc2-mm2.orig/include/linux/list.h 2007-03-07 11:21:15.000000000 +1100 +++ linux-2.6.21-rc2-mm2/include/linux/list.h 2007-03-07 11:22:57.000000000 +1100 @@ -333,6 +333,20 @@ static inline void __list_splice(struct at->prev = last; } +static inline void __list_splice_tail(struct list_head *list, + struct list_head *head) +{ + struct list_head *first = list->next; + struct list_head *last = list->prev; + struct list_head *at = head->prev; + + first->prev = at; + at->next = first; + + last->next = head; + head->prev = last; +} + /** * list_splice - join two lists * @list: the new list to add. @@ -345,6 +359,18 @@ static inline void list_splice(struct li } /** + * list_splice_tail - join two lists at one's tail + * @list: the new list to add. + * @head: the place to add it in the first list. + */ +static inline void list_splice_tail(struct list_head *list, + struct list_head *head) +{ + if (!list_empty(list)) + __list_splice_tail(list, head); +} + +/** * list_splice_init - join two lists and reinitialise the emptied list. * @list: the new list to add. * @head: the place to add it in the first list. @@ -417,6 +443,22 @@ static inline void list_splice_init_rcu( } /** + * list_splice_tail_init - join 2 lists at one's tail & reinitialise emptied + * @list: the new list to add. + * @head: the place to add it in the first list. + * + * The list at @list is reinitialised + */ +static inline void list_splice_tail_init(struct list_head *list, + struct list_head *head) +{ + if (!list_empty(list)) { + __list_splice_tail(list, head); + INIT_LIST_HEAD(list); + } +} + +/** * list_entry - get the struct for this entry * @ptr: the &struct list_head pointer. * @type: the type of the struct this is embedded in. -- -ck