[sheepdog] [PATCH 5/8] unralate list.h, util.h to compiler.h

Liu Yuan namei.unix at gmail.com
Fri Apr 3 05:20:51 CEST 2015


From: Liu Yuan <liuyuan at cmss.chinamobile.com>

This is a preparation patch. list.h and util.h will be used by shared library
and exported to the use.

Signed-off-by: Liu Yuan <liuyuan at cmss.chinamobile.com>
---
 include/compiler.h |  9 ---------
 include/list.h     |  2 --
 include/util.h     | 14 +++++++++++++-
 lib/util.c         |  3 +++
 4 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/include/compiler.h b/include/compiler.h
index 2fbd2a4..3c68b75 100644
--- a/include/compiler.h
+++ b/include/compiler.h
@@ -23,17 +23,10 @@
 
 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
 
-#define __LOCAL(var, line) __ ## var ## line
-#define _LOCAL(var, line) __LOCAL(var, line)
-#define LOCAL(var) _LOCAL(var, __LINE__)
-
 #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)
-
 #define __packed __attribute((packed))
 
 #define asmlinkage  __attribute__((regparm(0)))
@@ -43,8 +36,6 @@
 /* Force a compilation error if the condition is true */
 #define BUILD_BUG_ON(condition) ((void)sizeof(struct { int: -!!(condition); }))
 
-#define __must_check            __attribute__((warn_unused_result))
-
 #ifdef HAVE_SYS_SIGNALFD_H
 #include <sys/signalfd.h>
 #else
diff --git a/include/list.h b/include/list.h
index c1bd583..52a1d76 100644
--- a/include/list.h
+++ b/include/list.h
@@ -5,8 +5,6 @@
 
 #include <stdbool.h>
 
-#include "compiler.h"
-
 struct list_node {
 	struct list_node *next;
 	struct list_node *prev;
diff --git a/include/util.h b/include/util.h
index 2b2f34b..34a3e32 100644
--- a/include/util.h
+++ b/include/util.h
@@ -16,11 +16,23 @@
 #include <assert.h>
 
 #include "list.h"
-#include "compiler.h"
 
 #define SECTOR_SIZE (1U << 9)
 #define BLOCK_SIZE (1U << 12)
 
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
+
+#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)
+#define __must_check            __attribute__((warn_unused_result))
+
+#define __LOCAL(var, line) __ ## var ## line
+#define _LOCAL(var, line) __LOCAL(var, line)
+#define LOCAL(var) _LOCAL(var, __LINE__)
+
 #define round_up(x, y) roundup(x, y)
 #define round_down(x, y) (((x) / (y)) * (y))
 
diff --git a/lib/util.c b/lib/util.c
index af9747a..c50d298 100644
--- a/lib/util.c
+++ b/lib/util.c
@@ -19,6 +19,9 @@
 #include <ctype.h>
 #include <sys/xattr.h>
 #include <fcntl.h>
+#include <sys/eventfd.h>
+#include <sys/syscall.h>
+
 
 #include "util.h"
 
-- 
1.9.1




More information about the sheepdog mailing list