diff mbox

[ndctl,1/2] util: add a common ALIGN macro

Message ID 148625050793.27070.3913104369267731411.stgit@dwillia2-desk3.amr.corp.intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Dan Williams Feb. 4, 2017, 11:21 p.m. UTC
There are a couple locations where we locally define ALIGN(), add a
global definition before adding another local one.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 ndctl/builtin-dimm.c |    3 +--
 test/dax-pmd.c       |    3 +--
 util/size.h          |    4 ++++
 3 files changed, 6 insertions(+), 4 deletions(-)
diff mbox

Patch

diff --git a/ndctl/builtin-dimm.c b/ndctl/builtin-dimm.c
index 8a041cee8cab..637b10b47abf 100644
--- a/ndctl/builtin-dimm.c
+++ b/ndctl/builtin-dimm.c
@@ -17,6 +17,7 @@ 
 #include <limits.h>
 #include <syslog.h>
 #include <util/log.h>
+#include <util/size.h>
 #include <uuid/uuid.h>
 #include <util/json.h>
 #include <util/filter.h>
@@ -605,8 +606,6 @@  static struct namespace_label *label_base(struct nvdimm_data *ndd)
 	return (struct namespace_label *) base;
 }
 
-#define ALIGN(x, a) ((((unsigned long long) x) + (a - 1)) & ~(a - 1))
-#define BITS_PER_LONG (sizeof(unsigned long) * 8)
 static int label_write_index(struct nvdimm_data *ndd, int index, u32 seq)
 {
 	struct namespace_index *nsindex;
diff --git a/test/dax-pmd.c b/test/dax-pmd.c
index 47f254e398b2..831b1f0a6572 100644
--- a/test/dax-pmd.c
+++ b/test/dax-pmd.c
@@ -11,11 +11,10 @@ 
 #include <stdlib.h>
 #include <linux/fs.h>
 #include <test.h>
+#include <util/size.h>
 #include <linux/fiemap.h>
 
 #define NUM_EXTENTS 5
-#define HPAGE_SIZE (2 << 20)
-#define ALIGN(x, a) ((((unsigned long long) x) + (a - 1)) & ~(a - 1))
 #define fail() fprintf(stderr, "%s: failed at: %d\n", __func__, __LINE__)
 #define faili(i) fprintf(stderr, "%s: failed at: %d: %d\n", __func__, __LINE__, i)
 #define TEST_FILE "test_dax_data"
diff --git a/util/size.h b/util/size.h
index 776363fd19e9..4af14eb7d150 100644
--- a/util/size.h
+++ b/util/size.h
@@ -14,4 +14,8 @@ 
 unsigned long long parse_size64(const char *str);
 unsigned long long __parse_size64(const char *str, unsigned long long *units);
 
+#define ALIGN(x, a) ((((unsigned long long) x) + (a - 1)) & ~(a - 1))
+#define BITS_PER_LONG (sizeof(unsigned long) * 8)
+#define HPAGE_SIZE (2 << 20)
+
 #endif /* _NDCTL_SIZE_H_ */