[sheepdog] [PATCH 1/7] sheep: some macro preparation for sbd kernem modual

Liu Yuan namei.unix at gmail.com
Sat May 24 15:41:37 CEST 2014


From: Liu Yuan <tailai.ly at taobao.com>

Signed-off-by: Liu Yuan <namei.unix at gmail.com>
---
 include/sheepdog_proto.h | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/include/sheepdog_proto.h b/include/sheepdog_proto.h
index 9361bad..dff8728 100644
--- a/include/sheepdog_proto.h
+++ b/include/sheepdog_proto.h
@@ -11,15 +11,20 @@
 #ifndef __SHEEPDOG_PROTO_H__
 #define __SHEEPDOG_PROTO_H__
 
-#include <inttypes.h>
-#include <stdint.h>
+#ifdef __KERNEL__
+# define UINT64_MAX (18446744073709551615ULL)
+# define UINT64_C(x) ((x) + (UINT64_MAX - UINT64_MAX))
+#else
+# include <inttypes.h>
+# include <stdint.h>
+# include <string.h>
+# include "compiler.h"
+# include "bitops.h"
+#endif
+
 #include <stdbool.h>
-#include <string.h>
 #include <linux/limits.h>
 
-#include "compiler.h"
-#include "bitops.h"
-
 #define SD_PROTO_VER 0x02
 
 /* This or later version supports trimming zero sectors from read response */
@@ -371,10 +376,12 @@ static inline uint32_t sd_hash_vdi(const char *name)
 	return (uint32_t)(hval & (SD_NR_VDIS - 1));
 }
 
+#ifndef __KERNEL__
 static inline uint64_t hash_64(uint64_t val, unsigned int bits)
 {
 	return sd_hash_64(val) >> (64 - bits);
 }
+#endif
 
 static inline bool is_vdi_obj(uint64_t oid)
 {
-- 
1.8.1.2




More information about the sheepdog mailing list