All of lore.kernel.org
 help / color / mirror / Atom feed
* [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

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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.