[sheepdog] [PATCH v2 1/6] move container_of to compiler.h
MORITA Kazutaka
morita.kazutaka at gmail.com
Tue Sep 24 11:08:10 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 9fd4926..93b1a72 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>
@@ -20,6 +21,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 09e6d6b..928eda6 100644
--- a/include/rbtree.h
+++ b/include/rbtree.h
@@ -1,6 +1,8 @@
#ifndef __RBTREE_H_
#define __RBTREE_H_
+#include "compiler.h"
+
/* We have to be 64-bytes aligned to get 32/64 bits compatibility */
struct rb_node {
unsigned long rb_parent_color __attribute__ ((aligned (8)));
--
1.8.1.2
More information about the sheepdog
mailing list