erofs-utils: move list_head.h to include/erofs
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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
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@@ -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_INLINEinclude/erofs/defs.h renamed from mkfs/erofs_types.h +48
-18@@ -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@@ -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@@ -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)/includemkfs/erofs_cache.c +1
-1@@ -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@@ -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
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,
PATCH 1/2 erofs-utils: move list_head.h to include/erofs
In reply to Gao XiangQuoted 95 lines · Gao Xiang
In order to avoid name conficts, move it to
the sub-directory instead and rename tolist.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@@ -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@@ -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@@ -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@@ -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@@ -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
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,