* [PATCH 1/2] mtd-utils: Add macros to include/common.h
@ 2014-10-16 12:02 hujianyang
2014-10-16 12:08 ` [PATCH 2/2] mtd-utils: Remove duplicate macros from mkfs.ubifs/def.h hujianyang
2014-10-20 10:49 ` [PATCH 1/2] mtd-utils: Add macros to include/common.h Artem Bityutskiy
0 siblings, 2 replies; 5+ messages in thread
From: hujianyang @ 2014-10-16 12:02 UTC (permalink / raw)
To: Artem Bityutskiy; +Cc: linux-mtd
This patch adds four macros:
ALIGN, __ALIGN_MASK, min_t and max_t
to include/common.h.
Signed-off-by: hujianyang <hujianyang@huawei.com>
---
include/common.h | 15 +++++++++++++++
1 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/include/common.h b/include/common.h
index 6895e5c..9b8804a 100644
--- a/include/common.h
+++ b/include/common.h
@@ -47,6 +47,21 @@ extern "C" {
#define min(a, b) MIN(a, b) /* glue for linux kernel source */
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
+#define ALIGN(x,a) __ALIGN_MASK(x,(typeof(x))(a)-1)
+#define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask))
+
+#define min_t(t,x,y) ({ \
+ typeof((x)) _x = (x); \
+ typeof((y)) _y = (y); \
+ (_x < _y) ? _x : _y; \
+})
+
+#define max_t(t,x,y) ({ \
+ typeof((x)) _x = (x); \
+ typeof((y)) _y = (y); \
+ (_x > _y) ? _x : _y; \
+})
+
#ifndef O_CLOEXEC
#define O_CLOEXEC 0
#endif
--
1.6.0.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] mtd-utils: Remove duplicate macros from mkfs.ubifs/def.h
2014-10-16 12:02 [PATCH 1/2] mtd-utils: Add macros to include/common.h hujianyang
@ 2014-10-16 12:08 ` hujianyang
2014-10-20 10:51 ` Artem Bityutskiy
2014-10-20 10:49 ` [PATCH 1/2] mtd-utils: Add macros to include/common.h Artem Bityutskiy
1 sibling, 1 reply; 5+ messages in thread
From: hujianyang @ 2014-10-16 12:08 UTC (permalink / raw)
To: Artem Bityutskiy; +Cc: linux-mtd
These macros have been moved to include/common.h. This patch removes
duplicate macros from mkfs.ubifs/def.h and include these macros from
common.h
As each file which include common.h must define a PROGRAM_NAME, this
patch also adds PROGRAM_NAME for every c file in mkfs.ubifs/
Signed-off-by: hujianyang <hujianyang@huawei.com>
---
mkfs.ubifs/compr.c | 2 ++
mkfs.ubifs/defs.h | 15 ---------------
mkfs.ubifs/devtable.c | 2 ++
mkfs.ubifs/lpt.c | 2 ++
mkfs.ubifs/mkfs.ubifs.h | 1 +
5 files changed, 7 insertions(+), 15 deletions(-)
diff --git a/mkfs.ubifs/compr.c b/mkfs.ubifs/compr.c
index 4152b6a..6d62033 100644
--- a/mkfs.ubifs/compr.c
+++ b/mkfs.ubifs/compr.c
@@ -20,6 +20,8 @@
* Zoltan Sogor
*/
+#define PROGRAM_NAME "compr"
+
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
diff --git a/mkfs.ubifs/defs.h b/mkfs.ubifs/defs.h
index 06cf9e5..1fa3316 100644
--- a/mkfs.ubifs/defs.h
+++ b/mkfs.ubifs/defs.h
@@ -29,21 +29,6 @@
#define le32_to_cpu(x) (t32((x)))
#define le64_to_cpu(x) (t64((x)))
-#define ALIGN(x,a) __ALIGN_MASK(x,(typeof(x))(a)-1)
-#define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask))
-
-#define min_t(t,x,y) ({ \
- typeof((x)) _x = (x); \
- typeof((y)) _y = (y); \
- (_x < _y) ? _x : _y; \
-})
-
-#define max_t(t,x,y) ({ \
- typeof((x)) _x = (x); \
- typeof((y)) _y = (y); \
- (_x > _y) ? _x : _y; \
-})
-
#define unlikely(x) (x)
#define ubifs_assert(x) ({})
diff --git a/mkfs.ubifs/devtable.c b/mkfs.ubifs/devtable.c
index dee035d..2358197 100644
--- a/mkfs.ubifs/devtable.c
+++ b/mkfs.ubifs/devtable.c
@@ -44,6 +44,8 @@
* for more information about what the device table is.
*/
+#define PROGRAM_NAME "devtable"
+
#include "mkfs.ubifs.h"
#include "hashtable/hashtable.h"
#include "hashtable/hashtable_itr.h"
diff --git a/mkfs.ubifs/lpt.c b/mkfs.ubifs/lpt.c
index f6d4352..94e8f9d 100644
--- a/mkfs.ubifs/lpt.c
+++ b/mkfs.ubifs/lpt.c
@@ -20,6 +20,8 @@
* Artem Bityutskiy
*/
+#define PROGRAM_NAME "lpt"
+
#include "mkfs.ubifs.h"
/**
diff --git a/mkfs.ubifs/mkfs.ubifs.h b/mkfs.ubifs/mkfs.ubifs.h
index 6030c48..6f6feb8 100644
--- a/mkfs.ubifs/mkfs.ubifs.h
+++ b/mkfs.ubifs/mkfs.ubifs.h
@@ -51,6 +51,7 @@
#include "crc16.h"
#include "ubifs-media.h"
#include "ubifs.h"
+#include "common.h"
#include "key.h"
#include "lpt.h"
#include "compr.h"
--
1.6.0.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] mtd-utils: Add macros to include/common.h
2014-10-16 12:02 [PATCH 1/2] mtd-utils: Add macros to include/common.h hujianyang
2014-10-16 12:08 ` [PATCH 2/2] mtd-utils: Remove duplicate macros from mkfs.ubifs/def.h hujianyang
@ 2014-10-20 10:49 ` Artem Bityutskiy
1 sibling, 0 replies; 5+ messages in thread
From: Artem Bityutskiy @ 2014-10-20 10:49 UTC (permalink / raw)
To: hujianyang; +Cc: linux-mtd
On Thu, 2014-10-16 at 20:02 +0800, hujianyang wrote:
> This patch adds four macros:
>
> ALIGN, __ALIGN_MASK, min_t and max_t
>
> to include/common.h.
>
> Signed-off-by: hujianyang <hujianyang@huawei.com>
Hi, pushed this one to mtd-utils.git, thanks!
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] mtd-utils: Remove duplicate macros from mkfs.ubifs/def.h
2014-10-16 12:08 ` [PATCH 2/2] mtd-utils: Remove duplicate macros from mkfs.ubifs/def.h hujianyang
@ 2014-10-20 10:51 ` Artem Bityutskiy
2014-10-22 1:50 ` hujianyang
0 siblings, 1 reply; 5+ messages in thread
From: Artem Bityutskiy @ 2014-10-20 10:51 UTC (permalink / raw)
To: hujianyang; +Cc: linux-mtd
On Thu, 2014-10-16 at 20:08 +0800, hujianyang wrote:
> +#define PROGRAM_NAME "compr"
PROGRAM_NAME is the name of the end program, and there is no 'compre' or
'lpt' program.
Instead of this patch, I've pushed the one below, thanks!
>From dd183c2c8000d42073d19fefc2740dc50bafd287 Mon Sep 17 00:00:00 2001
From: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Date: Mon, 20 Oct 2014 13:47:09 +0300
Subject: [PATCH] mkfs.ubifs: start using common code
Several commonly used macros are now defined in 'common.h', let's start using
them in mkfs.ubifs, instead of duplicating them.
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
---
mkfs.ubifs/defs.h | 15 ---------------
mkfs.ubifs/mkfs.ubifs.c | 1 -
mkfs.ubifs/mkfs.ubifs.h | 4 ++++
3 files changed, 4 insertions(+), 16 deletions(-)
diff --git a/mkfs.ubifs/defs.h b/mkfs.ubifs/defs.h
index 06cf9e5..1fa3316 100644
--- a/mkfs.ubifs/defs.h
+++ b/mkfs.ubifs/defs.h
@@ -29,21 +29,6 @@
#define le32_to_cpu(x) (t32((x)))
#define le64_to_cpu(x) (t64((x)))
-#define ALIGN(x,a) __ALIGN_MASK(x,(typeof(x))(a)-1)
-#define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask))
-
-#define min_t(t,x,y) ({ \
- typeof((x)) _x = (x); \
- typeof((y)) _y = (y); \
- (_x < _y) ? _x : _y; \
-})
-
-#define max_t(t,x,y) ({ \
- typeof((x)) _x = (x); \
- typeof((y)) _y = (y); \
- (_x > _y) ? _x : _y; \
-})
-
#define unlikely(x) (x)
#define ubifs_assert(x) ({})
diff --git a/mkfs.ubifs/mkfs.ubifs.c b/mkfs.ubifs/mkfs.ubifs.c
index 200c8a5..ca17e2b 100644
--- a/mkfs.ubifs/mkfs.ubifs.c
+++ b/mkfs.ubifs/mkfs.ubifs.c
@@ -21,7 +21,6 @@
*/
#define _XOPEN_SOURCE 500 /* For realpath() */
-#define PROGRAM_NAME "mkfs.ubifs"
#include "mkfs.ubifs.h"
#include <crc32.h>
diff --git a/mkfs.ubifs/mkfs.ubifs.h b/mkfs.ubifs/mkfs.ubifs.h
index 6030c48..3edb79d 100644
--- a/mkfs.ubifs/mkfs.ubifs.h
+++ b/mkfs.ubifs/mkfs.ubifs.h
@@ -46,6 +46,10 @@
#include <uuid/uuid.h>
#include <sys/file.h>
+/* common.h requires the PROGRAM_NAME macro */
+#define PROGRAM_NAME "mkfs.ubifs"
+#include "common.h"
+
#include "libubi.h"
#include "defs.h"
#include "crc16.h"
--
1.9.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] mtd-utils: Remove duplicate macros from mkfs.ubifs/def.h
2014-10-20 10:51 ` Artem Bityutskiy
@ 2014-10-22 1:50 ` hujianyang
0 siblings, 0 replies; 5+ messages in thread
From: hujianyang @ 2014-10-22 1:50 UTC (permalink / raw)
To: dedekind1; +Cc: linux-mtd
On 2014/10/20 18:51, Artem Bityutskiy wrote:
> On Thu, 2014-10-16 at 20:08 +0800, hujianyang wrote:
>> +#define PROGRAM_NAME "compr"
>
> PROGRAM_NAME is the name of the end program, and there is no 'compre' or
> 'lpt' program.
>
> Instead of this patch, I've pushed the one below, thanks!
>
>>From dd183c2c8000d42073d19fefc2740dc50bafd287 Mon Sep 17 00:00:00 2001
> From: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
> Date: Mon, 20 Oct 2014 13:47:09 +0300
> Subject: [PATCH] mkfs.ubifs: start using common code
>
> Several commonly used macros are now defined in 'common.h', let's start using
> them in mkfs.ubifs, instead of duplicating them.
>
> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
> ---
> mkfs.ubifs/defs.h | 15 ---------------
> mkfs.ubifs/mkfs.ubifs.c | 1 -
> mkfs.ubifs/mkfs.ubifs.h | 4 ++++
> 3 files changed, 4 insertions(+), 16 deletions(-)
>
> diff --git a/mkfs.ubifs/defs.h b/mkfs.ubifs/defs.h
> index 06cf9e5..1fa3316 100644
> --- a/mkfs.ubifs/defs.h
> +++ b/mkfs.ubifs/defs.h
> @@ -29,21 +29,6 @@
> #define le32_to_cpu(x) (t32((x)))
> #define le64_to_cpu(x) (t64((x)))
>
> -#define ALIGN(x,a) __ALIGN_MASK(x,(typeof(x))(a)-1)
> -#define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask))
> -
> -#define min_t(t,x,y) ({ \
> - typeof((x)) _x = (x); \
> - typeof((y)) _y = (y); \
> - (_x < _y) ? _x : _y; \
> -})
> -
> -#define max_t(t,x,y) ({ \
> - typeof((x)) _x = (x); \
> - typeof((y)) _y = (y); \
> - (_x > _y) ? _x : _y; \
> -})
> -
> #define unlikely(x) (x)
>
> #define ubifs_assert(x) ({})
> diff --git a/mkfs.ubifs/mkfs.ubifs.c b/mkfs.ubifs/mkfs.ubifs.c
> index 200c8a5..ca17e2b 100644
> --- a/mkfs.ubifs/mkfs.ubifs.c
> +++ b/mkfs.ubifs/mkfs.ubifs.c
> @@ -21,7 +21,6 @@
> */
>
> #define _XOPEN_SOURCE 500 /* For realpath() */
> -#define PROGRAM_NAME "mkfs.ubifs"
>
> #include "mkfs.ubifs.h"
> #include <crc32.h>
> diff --git a/mkfs.ubifs/mkfs.ubifs.h b/mkfs.ubifs/mkfs.ubifs.h
> index 6030c48..3edb79d 100644
> --- a/mkfs.ubifs/mkfs.ubifs.h
> +++ b/mkfs.ubifs/mkfs.ubifs.h
> @@ -46,6 +46,10 @@
> #include <uuid/uuid.h>
> #include <sys/file.h>
>
> +/* common.h requires the PROGRAM_NAME macro */
> +#define PROGRAM_NAME "mkfs.ubifs"
> +#include "common.h"
> +
> #include "libubi.h"
> #include "defs.h"
> #include "crc16.h"
>
It's good~! Thanks~!
I'd like to resend the patch set of ubidump depend on these changes.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-10-22 1:51 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-16 12:02 [PATCH 1/2] mtd-utils: Add macros to include/common.h hujianyang
2014-10-16 12:08 ` [PATCH 2/2] mtd-utils: Remove duplicate macros from mkfs.ubifs/def.h hujianyang
2014-10-20 10:51 ` Artem Bityutskiy
2014-10-22 1:50 ` hujianyang
2014-10-20 10:49 ` [PATCH 1/2] mtd-utils: Add macros to include/common.h Artem Bityutskiy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).