Define pointer alignment macro in fio.h
authorTomohiro Kusumi <tkusumi@tuxera.com>
Mon, 23 Jan 2017 15:13:04 +0000 (00:13 +0900)
committerJens Axboe <axboe@fb.com>
Mon, 23 Jan 2017 15:26:12 +0000 (08:26 -0700)
Define PTR_ALIGN() as a common utility within the entire fio,
but inside FIO_INTERNAL guard since it could be a common name.

Signed-off-by: Tomohiro Kusumi <tkusumi@tuxera.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
backend.c
fio.h
lib/memalign.c
smalloc.c

index 4570d8d5e601a450fb54d757c980edb17009cfd3..fc647098d5792e5e4aaf5e366ffcb363e01921ca 100644 (file)
--- a/backend.c
+++ b/backend.c
@@ -76,9 +76,6 @@ int shm_id = 0;
 int temp_stall_ts;
 unsigned long done_secs = 0;
 
-#define PAGE_ALIGN(buf)        \
-       (char *) (((uintptr_t) (buf) + page_mask) & ~page_mask)
-
 #define JOB_START_TIMEOUT      (5 * 1000)
 
 static void sig_int(int sig)
@@ -1198,7 +1195,7 @@ static int init_io_u(struct thread_data *td)
 
        if (td->o.odirect || td->o.mem_align || td->o.oatomic ||
            td_ioengine_flagged(td, FIO_RAWIO))
-               p = PAGE_ALIGN(td->orig_buffer) + td->o.mem_align;
+               p = PTR_ALIGN(td->orig_buffer, page_mask) + td->o.mem_align;
        else
                p = td->orig_buffer;
 
diff --git a/fio.h b/fio.h
index b2dade90aa42f5242e60eb8d1696310dc8343290..14950fc89e3ab2009ee9f52c27377b1f0ee2ade2 100644 (file)
--- a/fio.h
+++ b/fio.h
@@ -619,6 +619,11 @@ extern int __must_check allocate_io_mem(struct thread_data *);
 extern void free_io_mem(struct thread_data *);
 extern void free_threads_shm(void);
 
+#ifdef FIO_INTERNAL
+#define PTR_ALIGN(ptr, mask)   \
+       (char *) (((uintptr_t) (ptr) + (mask)) & ~(mask))
+#endif
+
 /*
  * Reset stats after ramp time completes
  */
index cfd6e463ff924682d44346d130283094b7de3a07..1d1ba9ba2013ea2c3fdba579931ff1743989cdd7 100644 (file)
@@ -3,14 +3,12 @@
 #include <inttypes.h>
 
 #include "memalign.h"
+#include "../fio.h"
 
 struct align_footer {
        unsigned int offset;
 };
 
-#define PTR_ALIGN(ptr, mask)   \
-       (char *) (((uintptr_t) ((ptr) + (mask)) & ~(mask)))
-
 void *fio_memalign(size_t alignment, size_t size)
 {
        struct align_footer *f;
index d038ac64ccfb8dedbe2801ed3630dafbb121b97c..e48cfe8b1c11339d8e566743472795606668d588 100644 (file)
--- a/smalloc.c
+++ b/smalloc.c
@@ -13,6 +13,7 @@
 #include <limits.h>
 #include <fcntl.h>
 
+#include "fio.h"
 #include "mutex.h"
 #include "arch/arch.h"
 #include "os/os.h"
@@ -248,7 +249,7 @@ static void *postred_ptr(struct block_hdr *hdr)
        uintptr_t ptr;
 
        ptr = (uintptr_t) hdr + hdr->size - sizeof(unsigned int);
-       ptr = (ptr + int_mask) & ~int_mask;
+       ptr = (uintptr_t) PTR_ALIGN(ptr, int_mask);
 
        return (void *) ptr;
 }