From: "Alan D. Brunelle" <Alan.Brunelle@hp.com>
To: linux-btrace@vger.kernel.org
Subject: [PATCH] Added list_splice to btt/list.h
Date: Tue, 02 Oct 2007 16:39:22 +0000 [thread overview]
Message-ID: <4702743A.2050503@hp.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1 bytes --]
[-- Attachment #2: 0001-Added-list_splice-to-btt-list.h.patch --]
[-- Type: text/x-patch, Size: 2215 bytes --]
From ffeeb70251c738006077fade10f2f664f2a91199 Mon Sep 17 00:00:00 2001
From: Alan D. Brunelle <Alan.Brunelle@hp.com>
Date: Tue, 2 Oct 2007 12:08:34 -0400
Subject: [PATCH] Added list_splice to btt/list.h
list_splice is needed for the addition of btrecord/btreplay.
Signed-off-by: Alan D. Brunelle <Alan.Brunelle@hp.com>
---
btt/list.h | 47 +++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 47 insertions(+), 0 deletions(-)
diff --git a/btt/list.h b/btt/list.h
index f28f0fb..363c888 100644
--- a/btt/list.h
+++ b/btt/list.h
@@ -1,6 +1,28 @@
#ifndef _LINUX_LIST_H
#define _LINUX_LIST_H
+#include <stdio.h>
+
+#ifndef offsetof
+/**
+ * Get offset of a member
+ */
+#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
+#endif
+
+#ifndef container_of
+/**
+ * Casts a member of a structure out to the containing structure
+ * @param ptr the pointer to the member.
+ * @param type the type of the container struct this is embedded in.
+ * @param member the name of the member within the struct.
+ *
+ */
+#define container_of(ptr, type, member) ({ \
+ const typeof( ((type *)0)->member ) *__mptr = (ptr); \
+ (type *)( (char *)__mptr - offsetof(type,member) );})
+#endif
+
/*
* These are non-NULL pointers that will result in page faults
* under normal circumstances, used to verify that nobody uses
@@ -166,4 +188,29 @@ static inline void list_move_tail(struct list_head *list,
list_add_tail(list, head);
}
+static inline void __list_splice(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->next;
+
+ first->prev = head;
+ head->next = first;
+
+ last->next = at;
+ at->prev = last;
+}
+
+/**
+ * * list_splice - join two lists
+ * * @list: the new list to add.
+ * * @head: the place to add it in the first list.
+ * */
+static inline void list_splice(struct list_head *list, struct list_head *head)
+{
+ if (!list_empty(list))
+ __list_splice(list, head);
+}
+
#endif
--
1.5.2.5
reply other threads:[~2007-10-02 16:39 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=4702743A.2050503@hp.com \
--to=alan.brunelle@hp.com \
--cc=linux-btrace@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.