[sheepdog] [PATCH RFC 1/5] move container_of to compiler.h
MORITA Kazutaka
morita.kazutaka at gmail.com
Thu Sep 5 02:29:16 CEST 2013
From: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
rbtree.h needs container_of but doesn't need list.h.
Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
---
include/compiler.h | 5 +++++
include/list.h | 5 +----
include/rbtree.h | 2 ++
3 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/include/compiler.h b/include/compiler.h
index f495819..10f5b5e 100644
--- a/include/compiler.h
+++ b/include/compiler.h
@@ -12,6 +12,7 @@
#ifndef SD_COMPILER_H
#define SD_COMPILER_H
+#include <stddef.h>
#include <sys/syscall.h>
#include <unistd.h>
#include <time.h>
@@ -19,6 +20,10 @@
#include "config.h"
+#define container_of(ptr, type, member) ({ \
+ const typeof(((type *)0)->member) *__mptr = (ptr); \
+ (type *)((char *)__mptr - offsetof(type, member)); })
+
#define likely(x) __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect(!!(x), 0)
diff --git a/include/list.h b/include/list.h
index 392cc4b..97a88c3 100644
--- a/include/list.h
+++ b/include/list.h
@@ -3,12 +3,9 @@
/* taken from linux kernel */
-#include <stddef.h>
#include <stdbool.h>
-#define container_of(ptr, type, member) ({ \
- const typeof(((type *)0)->member) *__mptr = (ptr); \
- (type *)((char *)__mptr - offsetof(type, member)); })
+#include "compiler.h"
struct list_node {
struct list_node *next;
diff --git a/include/rbtree.h b/include/rbtree.h
index b3b023e..ff18ccc 100644
--- a/include/rbtree.h
+++ b/include/rbtree.h
@@ -1,6 +1,8 @@
#ifndef __RBTREE_H_
#define __RBTREE_H_
+#include "compiler.h"
+
struct rb_node {
unsigned long rb_parent_color;
#define RB_RED 0
--
1.7.9.5
More information about the sheepdog
mailing list