Skip to contentSkip to conversation

erofs-utils: move list_head.h to include/erofs

PATCH New Gao Xiang 2 participants 4 messages Dec 25, 2018 – Dec 27, 2018

lore
Share & tools
lore

Gao Xiang

author
#0 lore raw

PATCH 1/2 erofs-utils: move list_head.h to include/erofs

In order to avoid name conficts, move it to
the sub-directory instead and rename to list.h.

Signed-off-by Gao Xiang <gaoxiang25 at huawei.com>
---
 include/{list_head.h => erofs/list.h} | 6 +++---
 mkfs/erofs_cache.h                    | 2 +-
 mkfs/mkfs_erofs.h                     | 2 +-
 mkfs/mkfs_file.c                      | 2 +-
 mkfs/mkfs_file.h                      | 2 +-
 mkfs/mkfs_inode.h                     | 2 +-
 6 files changed, 8 insertions(+), 8 deletions(-)
 rename include/{list_head.h => erofs/list.h} (97%)
include/erofs/list.h renamed from include/list_head.h +3 -3
similarity index 97%
rename from include/list_head.h
rename to include/erofs/list.h
index adbf561..8dcbc5b 100644
@@ -1,13 +1,13 @@
 /* SPDX-License-Identifier: GPL-2.0+ */
 /*
- * list_head.h
+ * include/erofs/list.h
  *
  * Copyright (C) 2018 HUAWEI, Inc.
  *             http://www.huawei.com/
  * Created by Li Guifu <bluce.liguifu at huawei.com>
  */
-#ifndef __CONFIG_LIST_H
-#define __CONFIG_LIST_H
+#ifndef __EROFS_LIST_HEAD_H
+#define __EROFS_LIST_HEAD_H
 
 #include <assert.h>
 #include <stddef.h>
mkfs/erofs_cache.h +1 -1
index ca0702a..989853b 100644
@@ -9,7 +9,7 @@
 #ifndef __EROFS_CACHE_H__
 #define __EROFS_CACHE_H__
 #include "mkfs_erofs.h"
-#include "list_head.h"
+#include <erofs/list.h>
 
 enum erofs_meta_type {
 	EROFS_META_INODE,
mkfs/mkfs_erofs.h +1 -1
index 7fdc4c5..26f891c 100644
@@ -11,7 +11,7 @@
 #define __EROFS_MKFS_H
 
 #include <linux/limits.h>
-#include "list_head.h"
+#include <erofs/list.h>
 #include "erofs_types.h"
 
 typedef unsigned int __u32;
mkfs/mkfs_file.c +1 -1
index 9aa62e2..bb9877e 100644
@@ -28,7 +28,7 @@
 #define O_BINARY 0
 #endif
 #include "erofs_types.h"
-#include "list_head.h"
+#include <erofs/list.h>
 #include "erofs_cache.h"
 #include "erofs_compressor.h"
 
mkfs/mkfs_file.h +1 -1
index 3b23d00..852e92f 100644
@@ -14,7 +14,7 @@
 #include <sys/types.h>
 #include <stdio.h>
 #include <unistd.h>
-#include "list_head.h"
+#include <erofs/list.h>
 #include "mkfs_erofs.h"
 
 #define FILE_TYPE_NONE (0)
mkfs/mkfs_inode.h +1 -1
index 100e788..8a9b81e 100644
@@ -9,7 +9,7 @@
 #ifndef CONFIG_EROFS_MKFS_INODE_H
 #define CONFIG_EROFS_MKFS_INODE_H
 
-#include "list_head.h"
+#include <erofs/list.h>
 #include "erofs_cache.h"
 #include "mkfs_file.h"
 
Signature · 1 line
2.14.4
author
#1 lore raw

PATCH 2/2 erofs-utils: introduce a unique header for definitions

Signed-off-by Gao Xiang <gaoxiang25 at huawei.com>
---
 configure.ac                               | 13 +++++-
 mkfs/erofs_types.h => include/erofs/defs.h | 66 ++++++++++++++++++++++--------
 include/erofs/list.h                       |  9 +---
 mkfs/Makefile.am                           |  1 -
 mkfs/erofs_cache.c                         |  2 +-
 mkfs/mkfs_erofs.h                          |  1 -
 mkfs/mkfs_file.c                           |  1 -
 7 files changed, 62 insertions(+), 31 deletions(-)
 rename mkfs/erofs_types.h => include/erofs/defs.h (59%)
configure.ac +12 -1
index 524252f..d9d6e0b 100644
@@ -76,7 +76,18 @@ AC_ARG_WITH(lz4,
   ])
 
 # Checks for header files.
-AC_CHECK_HEADERS([fcntl.h inttypes.h limits.h stddef.h stdint.h stdlib.h string.h sys/time.h unistd.h])
+AC_CHECK_HEADERS(m4_flatten([
+	fcntl.h
+	inttypes.h
+	linux/types.h
+	limits.h
+	stddef.h
+	stdint.h
+	stdlib.h
+	string.h
+	sys/time.h
+	unistd.h
+]))
 
 # Checks for typedefs, structures, and compiler characteristics.
 AC_C_INLINE
include/erofs/defs.h renamed from mkfs/erofs_types.h +48 -18

82 lines not on this page · raw message

include/erofs/list.h +1 -8
index 8dcbc5b..aeef713 100644
@@ -9,20 +9,13 @@
 #ifndef __EROFS_LIST_HEAD_H
 #define __EROFS_LIST_HEAD_H
 
-#include <assert.h>
-#include <stddef.h>
+#include <erofs/defs.h>
 
 struct list_head {
 	struct list_head *prev;
 	struct list_head *next;
 };
 
-#define container_of(ptr, type, member)                                        \
-	({                                                                     \
-		const typeof(((type *)0)->member) *__mptr = (ptr);             \
-		(type *)((char *)__mptr - offsetof(type, member));             \
-	})
-
 #define LIST_HEAD_INIT(name)                                                   \
 	{                                                                      \
 		&(name), &(name)                                               \
mkfs/Makefile.am +0 -1
index faddec1..a17cc8c 100644
@@ -19,7 +19,6 @@ noinst_HEADERS = erofs_config.h  \
 		 mkfs_erofs.h \
 		 erofs_compressor.h \
 		 erofs_io.h \
-		 erofs_types.h \
 		 mkfs_file.h
 
 mkfs_erofs_CFLAGS = -Wall -Werror -DEROFS_MKFS_VERSION=\"v1.0\" -I$(top_srcdir)/include
mkfs/erofs_cache.c +1 -1
index c8af3de..aecca98 100644
@@ -11,7 +11,7 @@
 #include <stdint.h>
 #include <errno.h>
 
-#include "erofs_types.h"
+#include <erofs/defs.h>
 #include "erofs_cache.h"
 #include "erofs_error.h"
 #include "erofs_debug.h"
mkfs/mkfs_erofs.h +0 -1
index 26f891c..e8b6f1b 100644
@@ -12,7 +12,6 @@
 
 #include <linux/limits.h>
 #include <erofs/list.h>
-#include "erofs_types.h"
 
 typedef unsigned int __u32;
 
mkfs/mkfs_file.c +0 -1
index bb9877e..382e9b6 100644
@@ -27,7 +27,6 @@
 #ifndef O_BINARY
 #define O_BINARY 0
 #endif
-#include "erofs_types.h"
 #include <erofs/list.h>
 #include "erofs_cache.h"
 #include "erofs_compressor.h"
Signature · 1 line
2.14.4
#2 lore raw

PATCH 2/2 erofs-utils: introduce a unique header for definitions

Quoted 195 lines · Gao Xiang
Signed-off-by Gao Xiang <gaoxiang25 at huawei.com>
---
 configure.ac                               | 13 +++++-
 mkfs/erofs_types.h => include/erofs/defs.h | 66 ++++++++++++++++++++++--------
 include/erofs/list.h                       |  9 +---
 mkfs/Makefile.am                           |  1 -
 mkfs/erofs_cache.c                         |  2 +-
 mkfs/mkfs_erofs.h                          |  1 -
 mkfs/mkfs_file.c                           |  1 -
 7 files changed, 62 insertions(+), 31 deletions(-)
 rename mkfs/erofs_types.h => include/erofs/defs.h (59%)
configure.ac +12 -1
index 524252f..d9d6e0b 100644
@@ -76,7 +76,18 @@ AC_ARG_WITH(lz4,
   ])
 
 # Checks for header files.
-AC_CHECK_HEADERS([fcntl.h inttypes.h limits.h stddef.h stdint.h stdlib.h string.h sys/time.h unistd.h])
+AC_CHECK_HEADERS(m4_flatten([
+	fcntl.h
+	inttypes.h
+	linux/types.h
+	limits.h
+	stddef.h
+	stdint.h
+	stdlib.h
+	string.h
+	sys/time.h
+	unistd.h
+]))
 
 # Checks for typedefs, structures, and compiler characteristics.
 AC_C_INLINE
include/erofs/defs.h renamed from mkfs/erofs_types.h +48 -18
similarity index 59%
rename from mkfs/erofs_types.h
rename to include/erofs/defs.h
index 11fa21b..f90aa19 100644
@@ -1,31 +1,60 @@
 /* SPDX-License-Identifier: GPL-2.0+ */
 /*
- * erofs_types.h
+ * include/erofs/defs.h
  *
  * Copyright (C) 2018 HUAWEI, Inc.
  *             http://www.huawei.com/
  * Created by Li Guifu <bluce.liguifu at huawei.com>
+ * Modified by Gao Xiang <gaoxiang25 at huawei.com>
  */
-#ifndef __EROFS_TYPES_H
-#define __EROFS_TYPES_H
-#include <inttypes.h>
-#include <endian.h>
-#include <linux/types.h>
-#include <sys/types.h>
-#include <asm/types.h>
+#ifndef __EROFS_DEFS_H
+#define __EROFS_DEFS_H
+
+#include <stddef.h>
 #include <stdint.h>
-#include <sys/cdefs.h>
 #include <assert.h>
-#include <bits/byteswap.h>
+#include <inttypes.h>
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifdef HAVE_LINUX_TYPES_H
+#include <linux/types.h>
+#endif
+
+/*
+ * container_of - cast a member of a structure out to the containing structure
+ * @ptr:	the pointer to the member.
+ * @type:	the type of the container struct this is embedded in.
+ * @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)); })
 
-#define u8  uint8_t
-#define u16 uint16_t
-#define u32 uint32_t
-#define u64 uint64_t
-#define s8  int8_t
-#define s16 int16_t
-#define s32 int32_t
-#define s64 int64_t
+typedef uint8_t         u8;
+typedef uint16_t        u16;
+typedef uint32_t        u32;
+typedef uint64_t        u64;
+
+#ifndef HAVE_LINUX_TYPES_H
+typedef u8	__u8;
+typedef u16	__u16;
+typedef u32	__u32;
+typedef u64	__u64;
+typedef u16	__le16;
+typedef u32	__le32;
+typedef u64	__le64;
+typedef u16	__be16;
+typedef u32	__be32;
+typedef u64	__be64;
+#endif
+
+typedef int8_t          s8;
+typedef int16_t         s16;
+typedef int32_t         s32;
+typedef int64_t         s64;
 
 #if __BYTE_ORDER == __LITTLE_ENDIAN
 /*
@@ -68,3 +97,4 @@
 #define BITS_TO_LONGS(nr)   DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long))
 
 #endif
+
include/erofs/list.h +1 -8
index 8dcbc5b..aeef713 100644
@@ -9,20 +9,13 @@
 #ifndef __EROFS_LIST_HEAD_H
 #define __EROFS_LIST_HEAD_H
 
-#include <assert.h>
-#include <stddef.h>
+#include <erofs/defs.h>
 
 struct list_head {
 	struct list_head *prev;
 	struct list_head *next;
 };
 
-#define container_of(ptr, type, member)                                        \
-	({                                                                     \
-		const typeof(((type *)0)->member) *__mptr = (ptr);             \
-		(type *)((char *)__mptr - offsetof(type, member));             \
-	})
-
 #define LIST_HEAD_INIT(name)                                                   \
 	{                                                                      \
 		&(name), &(name)                                               \
mkfs/Makefile.am +0 -1
index faddec1..a17cc8c 100644
@@ -19,7 +19,6 @@ noinst_HEADERS = erofs_config.h  \
 		 mkfs_erofs.h \
 		 erofs_compressor.h \
 		 erofs_io.h \
-		 erofs_types.h \
 		 mkfs_file.h
 
 mkfs_erofs_CFLAGS = -Wall -Werror -DEROFS_MKFS_VERSION=\"v1.0\" -I$(top_srcdir)/include
mkfs/erofs_cache.c +1 -1
index c8af3de..aecca98 100644
@@ -11,7 +11,7 @@
 #include <stdint.h>
 #include <errno.h>
 
-#include "erofs_types.h"
+#include <erofs/defs.h>
 #include "erofs_cache.h"
 #include "erofs_error.h"
 #include "erofs_debug.h"
mkfs/mkfs_erofs.h +0 -1
index 26f891c..e8b6f1b 100644
@@ -12,7 +12,6 @@
 
 #include <linux/limits.h>
 #include <erofs/list.h>
-#include "erofs_types.h"
 
 typedef unsigned int __u32;
 
mkfs/mkfs_file.c +0 -0
index bb9877e..382e9b6 100644

mkfs/mkfs_file.c line 32

Quoted 7 lines
mkfs/mkfs_file.c +0 -1
@@ -27,7 +27,6 @@
 #ifndef O_BINARY
 #define O_BINARY 0
 #endif
-#include "erofs_types.h"
 #include <erofs/list.h>
 #include "erofs_cache.h"
 #include "erofs_compressor.h"
Reviewed-by Li Guifu <bluce.liguifu at huawei.com>

Thanks,

#3 lore raw

PATCH 1/2 erofs-utils: move list_head.h to include/erofs

In reply to Gao Xiang
Quoted 95 lines · Gao Xiang

In order to avoid name conficts, move it to
the sub-directory instead and rename to list.h.

Signed-off-by Gao Xiang <gaoxiang25 at huawei.com>
---
 include/{list_head.h => erofs/list.h} | 6 +++---
 mkfs/erofs_cache.h                    | 2 +-
 mkfs/mkfs_erofs.h                     | 2 +-
 mkfs/mkfs_file.c                      | 2 +-
 mkfs/mkfs_file.h                      | 2 +-
 mkfs/mkfs_inode.h                     | 2 +-
 6 files changed, 8 insertions(+), 8 deletions(-)
 rename include/{list_head.h => erofs/list.h} (97%)
include/erofs/list.h renamed from include/list_head.h +3 -3
similarity index 97%
rename from include/list_head.h
rename to include/erofs/list.h
index adbf561..8dcbc5b 100644
@@ -1,13 +1,13 @@
 /* SPDX-License-Identifier: GPL-2.0+ */
 /*
- * list_head.h
+ * include/erofs/list.h
  *
  * Copyright (C) 2018 HUAWEI, Inc.
  *             http://www.huawei.com/
  * Created by Li Guifu <bluce.liguifu at huawei.com>
  */
-#ifndef __CONFIG_LIST_H
-#define __CONFIG_LIST_H
+#ifndef __EROFS_LIST_HEAD_H
+#define __EROFS_LIST_HEAD_H
 
 #include <assert.h>
 #include <stddef.h>
mkfs/erofs_cache.h +1 -1
index ca0702a..989853b 100644
@@ -9,7 +9,7 @@
 #ifndef __EROFS_CACHE_H__
 #define __EROFS_CACHE_H__
 #include "mkfs_erofs.h"
-#include "list_head.h"
+#include <erofs/list.h>
 
 enum erofs_meta_type {
 	EROFS_META_INODE,
mkfs/mkfs_erofs.h +1 -1
index 7fdc4c5..26f891c 100644
@@ -11,7 +11,7 @@
 #define __EROFS_MKFS_H
 
 #include <linux/limits.h>
-#include "list_head.h"
+#include <erofs/list.h>
 #include "erofs_types.h"
 
 typedef unsigned int __u32;
mkfs/mkfs_file.c +1 -1
index 9aa62e2..bb9877e 100644
@@ -28,7 +28,7 @@
 #define O_BINARY 0
 #endif
 #include "erofs_types.h"
-#include "list_head.h"
+#include <erofs/list.h>
 #include "erofs_cache.h"
 #include "erofs_compressor.h"
 
mkfs/mkfs_file.h +1 -1
index 3b23d00..852e92f 100644
@@ -14,7 +14,7 @@
 #include <sys/types.h>
 #include <stdio.h>
 #include <unistd.h>
-#include "list_head.h"
+#include <erofs/list.h>
 #include "mkfs_erofs.h"
 
 #define FILE_TYPE_NONE (0)
mkfs/mkfs_inode.h +0 -0
index 100e788..8a9b81e 100644

mkfs/mkfs_inode.h line 15

Quoted 8 lines
mkfs/mkfs_inode.h +1 -1
@@ -9,7 +9,7 @@
 #ifndef CONFIG_EROFS_MKFS_INODE_H
 #define CONFIG_EROFS_MKFS_INODE_H
 
-#include "list_head.h"
+#include <erofs/list.h>
 #include "erofs_cache.h"
 #include "mkfs_file.h"
 
Reviewed-by Li Guifu <bluce.liguifu at huawei.com>

Thanks,